From 56cff4aa485b7af59f4602558f7c9db524741764 Mon Sep 17 00:00:00 2001 From: Wen Guan Date: Mon, 5 Jun 2023 23:22:07 +0200 Subject: [PATCH] fix alembic --- ...0204f391c32d_add_poll_period_in_message.py | 2 +- .../53d0af715dab_add_site_throttler.py | 23 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/main/lib/idds/orm/base/alembic/versions/0204f391c32d_add_poll_period_in_message.py b/main/lib/idds/orm/base/alembic/versions/0204f391c32d_add_poll_period_in_message.py index 44006783..2e05119c 100644 --- a/main/lib/idds/orm/base/alembic/versions/0204f391c32d_add_poll_period_in_message.py +++ b/main/lib/idds/orm/base/alembic/versions/0204f391c32d_add_poll_period_in_message.py @@ -33,7 +33,7 @@ def upgrade() -> None: if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']: schema = context.get_context().version_table_schema if context.get_context().version_table_schema else '' - op.add_column('messages', sa.Column('poll_period', sa.Interval, default=datetime.timedelta(seconds=300), nullable=False), schema=schema) + op.add_column('messages', sa.Column('poll_period', sa.Interval, default=datetime.timedelta(seconds=300)), schema=schema) def downgrade() -> None: diff --git a/main/lib/idds/orm/base/alembic/versions/53d0af715dab_add_site_throttler.py b/main/lib/idds/orm/base/alembic/versions/53d0af715dab_add_site_throttler.py index d59c42e8..b56213e7 100644 --- a/main/lib/idds/orm/base/alembic/versions/53d0af715dab_add_site_throttler.py +++ b/main/lib/idds/orm/base/alembic/versions/53d0af715dab_add_site_throttler.py @@ -39,13 +39,13 @@ def upgrade() -> None: schema = context.get_context().version_table_schema if context.get_context().version_table_schema else '' op.add_column('requests', sa.Column('site', sa.String(50)), schema=schema) - op.create_index("REQUESTS_STATUS_SITE", "requests", ['status', 'site', 'request_id']) + op.create_index("REQUESTS_STATUS_SITE", "requests", ['status', 'site', 'request_id'], schema=schema) op.add_column('transforms', sa.Column('site', sa.String(50)), schema=schema) - op.create_index("TRANSFORMS_STATUS_SITE", "transforms", ['status', 'site', 'request_id', 'transform_id']) + op.create_index("TRANSFORMS_STATUS_SITE", "transforms", ['status', 'site', 'request_id', 'transform_id'], schema=schema) op.add_column('processings', sa.Column('site', sa.String(50)), schema=schema) - op.create_index("PROCESSINGS_STATUS_SITE", "processings", ['status', 'site', 'request_id', 'transform_id', 'processing_id']) + op.create_index("PROCESSINGS_STATUS_SITE", "processings", ['status', 'site', 'request_id', 'transform_id', 'processing_id'], schema=schema) op.add_column('messages', sa.Column('fetching_id', sa.Integer()), schema=schema) @@ -60,9 +60,10 @@ def upgrade() -> None: sa.Column('queue_contents', sa.Integer()), sa.Column("created_at", sa.DateTime, default=datetime.datetime.utcnow, nullable=False), sa.Column("updated_at", sa.DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow, nullable=False), - sa.Column('others', JSON())) - op.create_primary_key('THROTTLER_PK', 'throttlers', ['throttler_id']) - op.create_unique_constraint('THROTTLER_SITE_UQ', 'throttlers', ['site']) + sa.Column('others', JSON()), + schema=schema) + op.create_primary_key('THROTTLER_PK', 'throttlers', ['throttler_id'], schema=schema) + op.create_unique_constraint('THROTTLER_SITE_UQ', 'throttlers', ['site'], schema=schema) def downgrade() -> None: @@ -70,16 +71,16 @@ def downgrade() -> None: schema = context.get_context().version_table_schema if context.get_context().version_table_schema else '' op.drop_column('requests', 'site', schema=schema) - op.drop_index("REQUESTS_STATUS_SITE", "requests") + # op.drop_index("REQUESTS_STATUS_SITE", "requests", schema=schema) op.drop_column('transforms', 'site', schema=schema) - op.drop_index("TRANSFORMS_STATUS_SITE", "requests") + # op.drop_index("TRANSFORMS_STATUS_SITE", "transforms", schema=schema) op.drop_column('processings', 'site', schema=schema) - op.drop_index("PROCESSINGS_STATUS_SITE", "requests") + # op.drop_index("PROCESSINGS_STATUS_SITE", "processings", schema=schema) op.drop_column('messages', 'fetching_id', schema=schema) - op.drop_constraint('THROTTLER_SITE_UQ') - op.drop_constraint('THROTTLER_PK') + op.drop_constraint('THROTTLER_SITE_UQ', table_name='throttlers', schema=schema) + op.drop_constraint('THROTTLER_PK', table_name='throttlers', schema=schema) op.drop_table('throttlers')