From 5b492ee32166c6420ff1c28f3fa98095b360f420 Mon Sep 17 00:00:00 2001 From: wangyan Date: Tue, 24 Jul 2018 01:59:23 -0700 Subject: [PATCH] Update migrator for support new table admin_job --- tools/migration/db/alembic/postgres/db_meta.py | 17 ++++++++++++++++- .../postgres/migration_harbor/versions/1_6_0.py | 4 ++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tools/migration/db/alembic/postgres/db_meta.py b/tools/migration/db/alembic/postgres/db_meta.py index fe0f3557e..a29eb8cc5 100644 --- a/tools/migration/db/alembic/postgres/db_meta.py +++ b/tools/migration/db/alembic/postgres/db_meta.py @@ -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) \ No newline at end of file + 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"),) \ No newline at end of file diff --git a/tools/migration/db/alembic/postgres/migration_harbor/versions/1_6_0.py b/tools/migration/db/alembic/postgres/migration_harbor/versions/1_6_0.py index 5a282d16a..096bb1890 100644 --- a/tools/migration/db/alembic/postgres/migration_harbor/versions/1_6_0.py +++ b/tools/migration/db/alembic/postgres/migration_harbor/versions/1_6_0.py @@ -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():