From a204eff43ccbf0599f2800719aeb47d6bf5b2afd Mon Sep 17 00:00:00 2001 From: Joe <1264204425@qq.com> Date: Fri, 19 Jul 2024 22:56:36 +0800 Subject: [PATCH 1/2] feat: remove extra tracing app config table --- ..._remove_extra_tracing_app_config_table .py | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 api/migrations/versions/fecff1c3da27_remove_extra_tracing_app_config_table .py diff --git a/api/migrations/versions/fecff1c3da27_remove_extra_tracing_app_config_table .py b/api/migrations/versions/fecff1c3da27_remove_extra_tracing_app_config_table .py new file mode 100644 index 00000000000000..e5ffeb99714dbf --- /dev/null +++ b/api/migrations/versions/fecff1c3da27_remove_extra_tracing_app_config_table .py @@ -0,0 +1,49 @@ +"""remove extra tracing app config table + +Revision ID: fecff1c3da27 +Revises: 408176b91ad3 +Create Date: 2024-07-19 12:03:21.217463 + +""" +import sqlalchemy as sa +from alembic import op +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = 'fecff1c3da27' +down_revision = '408176b91ad3' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('tracing_app_configs') + + with op.batch_alter_table('trace_app_config', schema=None) as batch_op: + batch_op.drop_index('tracing_app_config_app_id_idx') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table( + 'tracing_app_configs', + sa.Column('id', postgresql.UUID(), server_default=sa.text('uuid_generate_v4()'), nullable=False), + sa.Column('app_id', postgresql.UUID(), nullable=False), + sa.Column('tracing_provider', sa.String(length=255), nullable=True), + sa.Column('tracing_config', postgresql.JSON(astext_type=sa.Text()), nullable=True), + sa.Column( + 'created_at', postgresql.TIMESTAMP(), server_default=sa.text('now()'), autoincrement=False, nullable=False + ), + sa.Column( + 'updated_at', postgresql.TIMESTAMP(), server_default=sa.text('now()'), autoincrement=False, nullable=False + ), + sa.PrimaryKeyConstraint('id', name='tracing_app_config_pkey') + ) + + with op.batch_alter_table('trace_app_config', schema=None) as batch_op: + batch_op.create_index('tracing_app_config_app_id_idx', ['app_id']) + + # ### end Alembic commands ### From 4aa8c4b261ebfc660877e496989c6daa3b4b4cd0 Mon Sep 17 00:00:00 2001 From: Joe <1264204425@qq.com> Date: Sat, 20 Jul 2024 00:48:43 +0800 Subject: [PATCH 2/2] feat: add idx_dataset_permissions_tenant_id --- .../fecff1c3da27_remove_extra_tracing_app_config_table .py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/api/migrations/versions/fecff1c3da27_remove_extra_tracing_app_config_table .py b/api/migrations/versions/fecff1c3da27_remove_extra_tracing_app_config_table .py index e5ffeb99714dbf..271b2490de1055 100644 --- a/api/migrations/versions/fecff1c3da27_remove_extra_tracing_app_config_table .py +++ b/api/migrations/versions/fecff1c3da27_remove_extra_tracing_app_config_table .py @@ -1,4 +1,4 @@ -"""remove extra tracing app config table +"""remove extra tracing app config table and add idx_dataset_permissions_tenant_id Revision ID: fecff1c3da27 Revises: 408176b91ad3 @@ -23,6 +23,9 @@ def upgrade(): with op.batch_alter_table('trace_app_config', schema=None) as batch_op: batch_op.drop_index('tracing_app_config_app_id_idx') + # idx_dataset_permissions_tenant_id + with op.batch_alter_table('dataset_permissions', schema=None) as batch_op: + batch_op.create_index('idx_dataset_permissions_tenant_id', ['tenant_id']) # ### end Alembic commands ### @@ -46,4 +49,6 @@ def downgrade(): with op.batch_alter_table('trace_app_config', schema=None) as batch_op: batch_op.create_index('tracing_app_config_app_id_idx', ['app_id']) + with op.batch_alter_table('dataset_permissions', schema=None) as batch_op: + batch_op.drop_index('idx_dataset_permissions_tenant_id') # ### end Alembic commands ###