Merge pull request #5384 from wy65701436/update-migrator-aj

Update migrator for admin job
This commit is contained in:
Qian Deng 2018-07-26 03:19:31 -04:00 committed by GitHub
commit 0f7eab38b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -281,4 +281,19 @@ class SchemaMigrations(Base):
__tablename__ = 'schema_migrations'
version = sa.Column(sa.BigInteger, primary_key=True)
dirty = sa.Column(sa.Boolean, nullable=False)
dirty = sa.Column(sa.Boolean, nullable=False)
class AdminJob(Base):
__tablename__ = 'admin_job'
id = sa.Column(sa.Integer, primary_key=True)
job_name = sa.Column(sa.String(64), nullable=False)
job_kind = sa.Column(sa.String(64), nullable=False)
cron_str = sa.Column(sa.String(256))
status = sa.Column(sa.String(64), nullable=False)
job_uuid = sa.Column(sa.String(64))
deleted = sa.Column(sa.Boolean, nullable=False, server_default='false')
creation_time = sa.Column(sa.TIMESTAMP, server_default=sa.text("'now'::timestamp"))
update_time = sa.Column(sa.TIMESTAMP, server_default=sa.text("'now'::timestamp"))
__table_args__ = (sa.Index('status', "job_uuid"),)

View File

@ -45,6 +45,10 @@ def upgrade():
SchemaMigrations.__table__.create(bind)
session.add(SchemaMigrations(version=1, dirty=False))
## Add table admin_job
AdminJob.__table__.create(bind)
op.execute('CREATE TRIGGER admin_job_update_time_at_modtime BEFORE UPDATE ON admin_job FOR EACH ROW EXECUTE PROCEDURE update_update_time_at_column();')
session.commit()
def downgrade():