From 16d1e71a9fc6fe39a81722a343c79733c14af55a Mon Sep 17 00:00:00 2001 From: John Davis Date: Wed, 29 May 2024 22:18:26 -0400 Subject: [PATCH] Add ts db migration: deleted column to api_keys tbl --- ...add_non_nullable_column_deleted_to_api_.py | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 lib/tool_shed/webapp/model/migrations/alembic/versions/1b5bf427db25_add_non_nullable_column_deleted_to_api_.py diff --git a/lib/tool_shed/webapp/model/migrations/alembic/versions/1b5bf427db25_add_non_nullable_column_deleted_to_api_.py b/lib/tool_shed/webapp/model/migrations/alembic/versions/1b5bf427db25_add_non_nullable_column_deleted_to_api_.py new file mode 100644 index 000000000000..de71c9666da4 --- /dev/null +++ b/lib/tool_shed/webapp/model/migrations/alembic/versions/1b5bf427db25_add_non_nullable_column_deleted_to_api_.py @@ -0,0 +1,44 @@ +"""add non-nullable column deleted to API keys + +Revision ID: 1b5bf427db25 +Revises: 969bbf7bcc29 +Create Date: 2024-05-29 21:53:53.516506 + +""" +import sqlalchemy as sa +from alembic import op +from sqlalchemy import ( + Boolean, + Column, +) + +from galaxy.model.database_object_names import build_index_name +from galaxy.model.migrations.util import ( + add_column, + drop_column, + drop_index, + transaction, +) + +# revision identifiers, used by Alembic. +revision = "1b5bf427db25" +down_revision = "969bbf7bcc29" +branch_labels = None +depends_on = None + +# database object names used in this revision +table_name = "api_keys" +column_name = "deleted" +index_name = build_index_name(table_name, column_name) + + +def upgrade(): + add_column( + table_name, Column(column_name, Boolean(), default=False, index=True, nullable=False, server_default=sa.false()) + ) + + +def downgrade(): + with transaction(): + drop_index(index_name, table_name) + drop_column(table_name, column_name)