2016-04-18 18:44:39 +00:00
|
|
|
from sqlalchemy.orm import relationship
|
2016-08-14 12:22:53 +00:00
|
|
|
from sqlalchemy import (
|
|
|
|
Column, Integer, DateTime, Unicode, PickleType, ForeignKey)
|
2016-04-18 18:44:39 +00:00
|
|
|
from szurubooru.db.base import Base
|
|
|
|
|
2016-08-14 12:22:53 +00:00
|
|
|
|
2016-04-18 18:44:39 +00:00
|
|
|
class Snapshot(Base):
|
|
|
|
__tablename__ = 'snapshot'
|
|
|
|
|
2016-04-21 16:59:44 +00:00
|
|
|
OPERATION_CREATED = 'created'
|
2016-04-18 18:44:39 +00:00
|
|
|
OPERATION_MODIFIED = 'modified'
|
|
|
|
OPERATION_DELETED = 'deleted'
|
|
|
|
|
|
|
|
snapshot_id = Column('id', Integer, primary_key=True)
|
|
|
|
creation_time = Column('creation_time', DateTime, nullable=False)
|
2016-08-14 12:22:53 +00:00
|
|
|
resource_type = Column(
|
|
|
|
'resource_type', Unicode(32), nullable=False, index=True)
|
2016-05-09 07:43:00 +00:00
|
|
|
resource_id = Column('resource_id', Integer, nullable=False, index=True)
|
2016-05-08 20:18:13 +00:00
|
|
|
resource_repr = Column('resource_repr', Unicode(64), nullable=False)
|
|
|
|
operation = Column('operation', Unicode(16), nullable=False)
|
2016-08-15 16:36:14 +00:00
|
|
|
user_id = Column(
|
2016-08-15 16:36:31 +00:00
|
|
|
'user_id',
|
|
|
|
Integer,
|
|
|
|
ForeignKey('user.id', ondelete='set null'),
|
|
|
|
nullable=True)
|
2016-04-18 18:44:39 +00:00
|
|
|
data = Column('data', PickleType)
|
|
|
|
|
|
|
|
user = relationship('User')
|