2017-02-05 22:19:05 +00:00
|
|
|
import sqlalchemy as sa
|
2017-02-04 00:08:12 +00:00
|
|
|
from szurubooru.model.base import Base
|
2016-04-18 18:44:39 +00:00
|
|
|
|
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'
|
2016-08-14 18:06:49 +00:00
|
|
|
OPERATION_MERGED = 'merged'
|
2016-04-18 18:44:39 +00:00
|
|
|
|
2017-02-05 22:19:05 +00:00
|
|
|
snapshot_id = sa.Column('id', sa.Integer, primary_key=True)
|
|
|
|
creation_time = sa.Column('creation_time', sa.DateTime, nullable=False)
|
|
|
|
operation = sa.Column('operation', sa.Unicode(16), nullable=False)
|
|
|
|
resource_type = sa.Column(
|
|
|
|
'resource_type', sa.Unicode(32), nullable=False, index=True)
|
|
|
|
resource_pkey = sa.Column(
|
|
|
|
'resource_pkey', sa.Integer, nullable=False, index=True)
|
|
|
|
resource_name = sa.Column(
|
2020-03-15 18:01:06 +00:00
|
|
|
'resource_name', sa.Unicode(128), nullable=False)
|
2017-02-05 22:19:05 +00:00
|
|
|
user_id = sa.Column(
|
2016-08-15 16:36:31 +00:00
|
|
|
'user_id',
|
2017-02-05 22:19:05 +00:00
|
|
|
sa.Integer,
|
|
|
|
sa.ForeignKey('user.id', ondelete='set null'),
|
2016-08-15 16:36:31 +00:00
|
|
|
nullable=True)
|
2017-02-05 22:19:05 +00:00
|
|
|
data = sa.Column('data', sa.PickleType)
|
2016-04-18 18:44:39 +00:00
|
|
|
|
2017-02-05 22:19:05 +00:00
|
|
|
user = sa.orm.relationship('User')
|