From 5f09a2419adf8d3a27eec84d2d94c5eb7ee6bb14 Mon Sep 17 00:00:00 2001 From: Wen Guan Date: Tue, 25 Apr 2023 19:13:21 +0200 Subject: [PATCH] update idds messages table null constraints --- ...5e466eb_update_message_null_constraints.py | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 main/lib/idds/orm/base/alembic/versions/6ca0e5e466eb_update_message_null_constraints.py diff --git a/main/lib/idds/orm/base/alembic/versions/6ca0e5e466eb_update_message_null_constraints.py b/main/lib/idds/orm/base/alembic/versions/6ca0e5e466eb_update_message_null_constraints.py new file mode 100644 index 00000000..b477aa3e --- /dev/null +++ b/main/lib/idds/orm/base/alembic/versions/6ca0e5e466eb_update_message_null_constraints.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# You may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0OA +# +# Authors: +# - Wen Guan, , 2023 + +"""update message null constraints + +Revision ID: 6ca0e5e466eb +Revises: 5e0aa2aa1fa3 +Create Date: 2023-04-25 16:58:29.975397+00:00 + +""" +from alembic import op +from alembic import context +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '6ca0e5e466eb' +down_revision = '5e0aa2aa1fa3' +branch_labels = None +depends_on = None + + +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.alter_column('messages', sa.Column('request_id'), nullable=True, schema=schema) + op.alter_column('messages', sa.Column('transform_id'), nullable=True, schema=schema) + op.alter_column('messages', sa.Column('processing_id'), nullable=True, schema=schema) + + +def downgrade() -> 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.alter_column('messages', sa.Column('request_id'), nullable=False, schema=schema) + op.alter_column('messages', sa.Column('transform_id'), nullable=False, schema=schema) + op.alter_column('messages', sa.Column('processing_id'), nullable=False, schema=schema)