mirror of
https://github.com/lucaspalomodevelop/indico-plugins.git
synced 2026-03-13 07:29:39 +00:00
LiveSync: Use PyIntEnum
This commit is contained in:
parent
79c567eab0
commit
414ca219a7
@ -10,7 +10,9 @@ from alembic import op
|
||||
from sqlalchemy.dialects import postgresql
|
||||
from sqlalchemy.sql.ddl import CreateSchema, DropSchema
|
||||
|
||||
from indico.core.db.sqlalchemy import UTCDateTime
|
||||
from indico.core.db.sqlalchemy import UTCDateTime, PyIntEnum
|
||||
|
||||
from indico_livesync.models.queue import ChangeType
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
@ -34,14 +36,13 @@ def upgrade():
|
||||
sa.Column('agent_id', sa.Integer(), nullable=False, index=True),
|
||||
sa.Column('timestamp', UTCDateTime(), nullable=False),
|
||||
sa.Column('processed', sa.Boolean(), nullable=False),
|
||||
sa.Column('change', sa.SmallInteger(), nullable=False),
|
||||
sa.Column('change', PyIntEnum(ChangeType), nullable=False),
|
||||
sa.Column('type', sa.String(), nullable=False),
|
||||
sa.Column('category_id', sa.String()),
|
||||
sa.Column('event_id', sa.String()),
|
||||
sa.Column('contrib_id', sa.String()),
|
||||
sa.Column('subcontrib_id', sa.String()),
|
||||
sa.ForeignKeyConstraint(['agent_id'], ['plugin_livesync.agents.id']),
|
||||
sa.CheckConstraint('change IN (1, 2, 3, 4, 5, 6)'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
schema='plugin_livesync')
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
||||
|
||||
from werkzeug.datastructures import ImmutableDict
|
||||
|
||||
from indico.core.db.sqlalchemy import db, UTCDateTime
|
||||
from indico.core.db.sqlalchemy import db, UTCDateTime, PyIntEnum
|
||||
from indico.util.date_time import now_utc
|
||||
from indico.util.string import return_ascii
|
||||
from indico.util.struct.enum import IndicoEnum
|
||||
@ -38,8 +38,7 @@ class ChangeType(int, IndicoEnum):
|
||||
|
||||
class LiveSyncQueueEntry(db.Model):
|
||||
__tablename__ = 'queues'
|
||||
__table_args__ = (db.CheckConstraint('change IN ({})'.format(', '.join(map(str, ChangeType)))),
|
||||
{'schema': 'plugin_livesync'})
|
||||
__table_args__ = {'schema': 'plugin_livesync'}
|
||||
|
||||
#: Entry ID
|
||||
id = db.Column(
|
||||
@ -71,7 +70,7 @@ class LiveSyncQueueEntry(db.Model):
|
||||
|
||||
#: the change type, a :class:`ChangeType`
|
||||
change = db.Column(
|
||||
db.SmallInteger,
|
||||
PyIntEnum(ChangeType),
|
||||
nullable=False
|
||||
)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user