From 2cc07e6112c83da9e8f641db374092320485f824 Mon Sep 17 00:00:00 2001 From: Joe Li Date: Fri, 16 Aug 2024 10:16:05 -0700 Subject: [PATCH] fix: try to prevent deadlocks when running upgrade (#29625) --- ...24_11-31_02f4f7811799_remove_sl__tables.py | 197 ------------------ ...7811799_remove_sl_dataset_columns_table.py | 56 +++++ ...49add7bfc_remove_sl_table_columns_table.py | 56 +++++ ...3_38f4144e8558_remove_sl_dataset_tables.py | 56 +++++ ...27_e53fd48cc078_remove_sl_dataset_users.py | 56 +++++ ...13_15-29_a6b32d2d07b1_remove_sl_columns.py | 80 +++++++ ...-13_15-31_007a1abffe7e_remove_sl_tables.py | 72 +++++++ ...3_15-33_48cbb571fa3a_remove_sl_datasets.py | 72 +++++++ 8 files changed, 448 insertions(+), 197 deletions(-) delete mode 100644 superset/migrations/versions/2024-05-24_11-31_02f4f7811799_remove_sl__tables.py create mode 100644 superset/migrations/versions/2024-05-24_11-31_02f4f7811799_remove_sl_dataset_columns_table.py create mode 100644 superset/migrations/versions/2024-08-13_15-17_39549add7bfc_remove_sl_table_columns_table.py create mode 100644 superset/migrations/versions/2024-08-13_15-23_38f4144e8558_remove_sl_dataset_tables.py create mode 100644 superset/migrations/versions/2024-08-13_15-27_e53fd48cc078_remove_sl_dataset_users.py create mode 100644 superset/migrations/versions/2024-08-13_15-29_a6b32d2d07b1_remove_sl_columns.py create mode 100644 superset/migrations/versions/2024-08-13_15-31_007a1abffe7e_remove_sl_tables.py create mode 100644 superset/migrations/versions/2024-08-13_15-33_48cbb571fa3a_remove_sl_datasets.py diff --git a/superset/migrations/versions/2024-05-24_11-31_02f4f7811799_remove_sl__tables.py b/superset/migrations/versions/2024-05-24_11-31_02f4f7811799_remove_sl__tables.py deleted file mode 100644 index 745da474a2a57..0000000000000 --- a/superset/migrations/versions/2024-05-24_11-31_02f4f7811799_remove_sl__tables.py +++ /dev/null @@ -1,197 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -"""remove sl_ tables - -Revision ID: 02f4f7811799 -Revises: f7b6750b67e8 -Create Date: 2024-05-24 11:31:57.115586 - -""" - -import sqlalchemy as sa -from alembic import op - -# revision identifiers, used by Alembic. -revision = "02f4f7811799" -down_revision = "f7b6750b67e8" - - -def upgrade(): - op.drop_table("sl_dataset_columns") - op.drop_table("sl_table_columns") - op.drop_table("sl_dataset_tables") - op.drop_table("sl_columns") - op.drop_table("sl_tables") - op.drop_table("sl_dataset_users") - op.drop_table("sl_datasets") - - -def downgrade(): - op.create_table( - "sl_datasets", - sa.Column("uuid", sa.Numeric(precision=16), nullable=True), - sa.Column("created_on", sa.DateTime(), nullable=True), - sa.Column("changed_on", sa.DateTime(), nullable=True), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("database_id", sa.Integer(), nullable=False), - sa.Column("is_physical", sa.Boolean(), nullable=True), - sa.Column("is_managed_externally", sa.Boolean(), nullable=False), - sa.Column("name", sa.Text(), nullable=True), - sa.Column("expression", sa.Text(), nullable=True), - sa.Column("external_url", sa.Text(), nullable=True), - sa.Column("extra_json", sa.Text(), nullable=True), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("changed_by_fk", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint( - ["changed_by_fk"], - ["ab_user.id"], - ), - sa.ForeignKeyConstraint( - ["created_by_fk"], - ["ab_user.id"], - ), - sa.ForeignKeyConstraint( - ["database_id"], - ["dbs.id"], - ), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("uuid"), - ) - op.create_table( - "sl_tables", - sa.Column("uuid", sa.Numeric(precision=16), nullable=True), - sa.Column("created_on", sa.DateTime(), nullable=True), - sa.Column("changed_on", sa.DateTime(), nullable=True), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("database_id", sa.Integer(), nullable=False), - sa.Column("is_managed_externally", sa.Boolean(), nullable=False), - sa.Column("catalog", sa.Text(), nullable=True), - sa.Column("schema", sa.Text(), nullable=True), - sa.Column("name", sa.Text(), nullable=True), - sa.Column("external_url", sa.Text(), nullable=True), - sa.Column("extra_json", sa.Text(), nullable=True), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("changed_by_fk", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint( - ["changed_by_fk"], - ["ab_user.id"], - ), - sa.ForeignKeyConstraint( - ["created_by_fk"], - ["ab_user.id"], - ), - sa.ForeignKeyConstraint( - ["database_id"], - ["dbs.id"], - ), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("uuid"), - ) - op.create_table( - "sl_columns", - sa.Column("uuid", sa.Numeric(precision=16), nullable=True), - sa.Column("created_on", sa.DateTime(), nullable=True), - sa.Column("changed_on", sa.DateTime(), nullable=True), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("is_aggregation", sa.Boolean(), nullable=False), - sa.Column("is_additive", sa.Boolean(), nullable=False), - sa.Column("is_dimensional", sa.Boolean(), nullable=False), - sa.Column("is_filterable", sa.Boolean(), nullable=False), - sa.Column("is_increase_desired", sa.Boolean(), nullable=False), - sa.Column("is_managed_externally", sa.Boolean(), nullable=False), - sa.Column("is_partition", sa.Boolean(), nullable=False), - sa.Column("is_physical", sa.Boolean(), nullable=False), - sa.Column("is_temporal", sa.Boolean(), nullable=False), - sa.Column("is_spatial", sa.Boolean(), nullable=False), - sa.Column("name", sa.Text(), nullable=True), - sa.Column("type", sa.Text(), nullable=True), - sa.Column("unit", sa.Text(), nullable=True), - sa.Column("expression", sa.Text(), nullable=True), - sa.Column("description", sa.Text(), nullable=True), - sa.Column("warning_text", sa.Text(), nullable=True), - sa.Column("external_url", sa.Text(), nullable=True), - sa.Column("extra_json", sa.Text(), nullable=True), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("changed_by_fk", sa.Integer(), nullable=True), - sa.Column("advanced_data_type", sa.Text(), nullable=True), - sa.ForeignKeyConstraint( - ["changed_by_fk"], - ["ab_user.id"], - ), - sa.ForeignKeyConstraint( - ["created_by_fk"], - ["ab_user.id"], - ), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("uuid"), - ) - op.create_table( - "sl_dataset_users", - sa.Column("dataset_id", sa.Integer(), nullable=False), - sa.Column("user_id", sa.Integer(), nullable=False), - sa.ForeignKeyConstraint( - ["dataset_id"], - ["sl_datasets.id"], - ), - sa.ForeignKeyConstraint( - ["user_id"], - ["ab_user.id"], - ), - sa.PrimaryKeyConstraint("dataset_id", "user_id"), - ) - op.create_table( - "sl_dataset_tables", - sa.Column("dataset_id", sa.Integer(), nullable=False), - sa.Column("table_id", sa.Integer(), nullable=False), - sa.ForeignKeyConstraint( - ["dataset_id"], - ["sl_datasets.id"], - ), - sa.ForeignKeyConstraint( - ["table_id"], - ["sl_tables.id"], - ), - sa.PrimaryKeyConstraint("dataset_id", "table_id"), - ) - op.create_table( - "sl_table_columns", - sa.Column("table_id", sa.Integer(), nullable=False), - sa.Column("column_id", sa.Integer(), nullable=False), - sa.ForeignKeyConstraint( - ["column_id"], - ["sl_columns.id"], - ), - sa.ForeignKeyConstraint( - ["table_id"], - ["sl_tables.id"], - ), - sa.PrimaryKeyConstraint("table_id", "column_id"), - ) - op.create_table( - "sl_dataset_columns", - sa.Column("dataset_id", sa.Integer(), nullable=False), - sa.Column("column_id", sa.Integer(), nullable=False), - sa.ForeignKeyConstraint( - ["column_id"], - ["sl_columns.id"], - ), - sa.ForeignKeyConstraint( - ["dataset_id"], - ["sl_datasets.id"], - ), - sa.PrimaryKeyConstraint("dataset_id", "column_id"), - ) diff --git a/superset/migrations/versions/2024-05-24_11-31_02f4f7811799_remove_sl_dataset_columns_table.py b/superset/migrations/versions/2024-05-24_11-31_02f4f7811799_remove_sl_dataset_columns_table.py new file mode 100644 index 0000000000000..f3c4f8c2c344b --- /dev/null +++ b/superset/migrations/versions/2024-05-24_11-31_02f4f7811799_remove_sl_dataset_columns_table.py @@ -0,0 +1,56 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""remove sl_dataset_columns tables + +Revision ID: 02f4f7811799 +Revises: f7b6750b67e8 +Create Date: 2024-05-24 11:31:57.115586 + +""" + +import sqlalchemy as sa +from alembic import op + +from superset.migrations.shared.constraints import drop_fks_for_table + +# revision identifiers, used by Alembic. +revision = "02f4f7811799" +down_revision = "f7b6750b67e8" + + +def upgrade(): + connection = op.get_bind() + if connection.dialect.name != "sqlite": + drop_fks_for_table("sl_dataset_columns") + op.drop_table("sl_dataset_columns") + + +def downgrade(): + op.create_table( + "sl_dataset_columns", + sa.Column("dataset_id", sa.Integer(), nullable=False), + sa.Column("column_id", sa.Integer(), nullable=False), + sa.ForeignKeyConstraint( + ["column_id"], + ["sl_columns.id"], + ), + sa.ForeignKeyConstraint( + ["dataset_id"], + ["sl_datasets.id"], + ), + sa.PrimaryKeyConstraint("dataset_id", "column_id"), + ) diff --git a/superset/migrations/versions/2024-08-13_15-17_39549add7bfc_remove_sl_table_columns_table.py b/superset/migrations/versions/2024-08-13_15-17_39549add7bfc_remove_sl_table_columns_table.py new file mode 100644 index 0000000000000..9fa8e8097b314 --- /dev/null +++ b/superset/migrations/versions/2024-08-13_15-17_39549add7bfc_remove_sl_table_columns_table.py @@ -0,0 +1,56 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""remove sl_table_columns_table + +Revision ID: 39549add7bfc +Revises: 02f4f7811799 +Create Date: 2024-08-13 15:17:23.273168 + +""" + +import sqlalchemy as sa +from alembic import op + +from superset.migrations.shared.constraints import drop_fks_for_table + +# revision identifiers, used by Alembic. +revision = "39549add7bfc" +down_revision = "02f4f7811799" + + +def upgrade(): + connection = op.get_bind() + if connection.dialect.name != "sqlite": + drop_fks_for_table("sl_table_columns") + op.drop_table("sl_table_columns") + + +def downgrade(): + op.create_table( + "sl_table_columns", + sa.Column("table_id", sa.Integer(), nullable=False), + sa.Column("column_id", sa.Integer(), nullable=False), + sa.ForeignKeyConstraint( + ["column_id"], + ["sl_columns.id"], + ), + sa.ForeignKeyConstraint( + ["table_id"], + ["sl_tables.id"], + ), + sa.PrimaryKeyConstraint("table_id", "column_id"), + ) diff --git a/superset/migrations/versions/2024-08-13_15-23_38f4144e8558_remove_sl_dataset_tables.py b/superset/migrations/versions/2024-08-13_15-23_38f4144e8558_remove_sl_dataset_tables.py new file mode 100644 index 0000000000000..7f5b75395bf2a --- /dev/null +++ b/superset/migrations/versions/2024-08-13_15-23_38f4144e8558_remove_sl_dataset_tables.py @@ -0,0 +1,56 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""remove sl_dataset_tables + +Revision ID: 38f4144e8558 +Revises: 39549add7bfc +Create Date: 2024-08-13 15:23:28.768963 + +""" + +import sqlalchemy as sa +from alembic import op + +from superset.migrations.shared.constraints import drop_fks_for_table + +# revision identifiers, used by Alembic. +revision = "38f4144e8558" +down_revision = "39549add7bfc" + + +def upgrade(): + connection = op.get_bind() + if connection.dialect.name != "sqlite": + drop_fks_for_table("sl_dataset_tables") + op.drop_table("sl_dataset_tables") + + +def downgrade(): + op.create_table( + "sl_dataset_tables", + sa.Column("dataset_id", sa.Integer(), nullable=False), + sa.Column("table_id", sa.Integer(), nullable=False), + sa.ForeignKeyConstraint( + ["dataset_id"], + ["sl_datasets.id"], + ), + sa.ForeignKeyConstraint( + ["table_id"], + ["sl_tables.id"], + ), + sa.PrimaryKeyConstraint("dataset_id", "table_id"), + ) diff --git a/superset/migrations/versions/2024-08-13_15-27_e53fd48cc078_remove_sl_dataset_users.py b/superset/migrations/versions/2024-08-13_15-27_e53fd48cc078_remove_sl_dataset_users.py new file mode 100644 index 0000000000000..e7e3881d318ad --- /dev/null +++ b/superset/migrations/versions/2024-08-13_15-27_e53fd48cc078_remove_sl_dataset_users.py @@ -0,0 +1,56 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""remove sl_dataset_users + +Revision ID: e53fd48cc078 +Revises: 38f4144e8558 +Create Date: 2024-08-13 15:27:11.589886 + +""" + +import sqlalchemy as sa +from alembic import op + +from superset.migrations.shared.constraints import drop_fks_for_table + +# revision identifiers, used by Alembic. +revision = "e53fd48cc078" +down_revision = "38f4144e8558" + + +def upgrade(): + connection = op.get_bind() + if connection.dialect.name != "sqlite": + drop_fks_for_table("sl_dataset_users") + op.drop_table("sl_dataset_users") + + +def downgrade(): + op.create_table( + "sl_dataset_users", + sa.Column("dataset_id", sa.Integer(), nullable=False), + sa.Column("user_id", sa.Integer(), nullable=False), + sa.ForeignKeyConstraint( + ["dataset_id"], + ["sl_datasets.id"], + ), + sa.ForeignKeyConstraint( + ["user_id"], + ["ab_user.id"], + ), + sa.PrimaryKeyConstraint("dataset_id", "user_id"), + ) diff --git a/superset/migrations/versions/2024-08-13_15-29_a6b32d2d07b1_remove_sl_columns.py b/superset/migrations/versions/2024-08-13_15-29_a6b32d2d07b1_remove_sl_columns.py new file mode 100644 index 0000000000000..d5fbf860abaad --- /dev/null +++ b/superset/migrations/versions/2024-08-13_15-29_a6b32d2d07b1_remove_sl_columns.py @@ -0,0 +1,80 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""remove sl_columns + +Revision ID: a6b32d2d07b1 +Revises: e53fd48cc078 +Create Date: 2024-08-13 15:29:33.135672 + +""" + +import sqlalchemy as sa +from alembic import op + +from superset.migrations.shared.constraints import drop_fks_for_table + +# revision identifiers, used by Alembic. +revision = "a6b32d2d07b1" +down_revision = "e53fd48cc078" + + +def upgrade(): + connection = op.get_bind() + if connection.dialect.name != "sqlite": + drop_fks_for_table("sl_columns") + op.drop_table("sl_columns") + + +def downgrade(): + op.create_table( + "sl_columns", + sa.Column("uuid", sa.Numeric(precision=16), nullable=True), + sa.Column("created_on", sa.DateTime(), nullable=True), + sa.Column("changed_on", sa.DateTime(), nullable=True), + sa.Column("id", sa.Integer(), nullable=False), + sa.Column("is_aggregation", sa.Boolean(), nullable=False), + sa.Column("is_additive", sa.Boolean(), nullable=False), + sa.Column("is_dimensional", sa.Boolean(), nullable=False), + sa.Column("is_filterable", sa.Boolean(), nullable=False), + sa.Column("is_increase_desired", sa.Boolean(), nullable=False), + sa.Column("is_managed_externally", sa.Boolean(), nullable=False), + sa.Column("is_partition", sa.Boolean(), nullable=False), + sa.Column("is_physical", sa.Boolean(), nullable=False), + sa.Column("is_temporal", sa.Boolean(), nullable=False), + sa.Column("is_spatial", sa.Boolean(), nullable=False), + sa.Column("name", sa.Text(), nullable=True), + sa.Column("type", sa.Text(), nullable=True), + sa.Column("unit", sa.Text(), nullable=True), + sa.Column("expression", sa.Text(), nullable=True), + sa.Column("description", sa.Text(), nullable=True), + sa.Column("warning_text", sa.Text(), nullable=True), + sa.Column("external_url", sa.Text(), nullable=True), + sa.Column("extra_json", sa.Text(), nullable=True), + sa.Column("created_by_fk", sa.Integer(), nullable=True), + sa.Column("changed_by_fk", sa.Integer(), nullable=True), + sa.Column("advanced_data_type", sa.Text(), nullable=True), + sa.ForeignKeyConstraint( + ["changed_by_fk"], + ["ab_user.id"], + ), + sa.ForeignKeyConstraint( + ["created_by_fk"], + ["ab_user.id"], + ), + sa.PrimaryKeyConstraint("id"), + sa.UniqueConstraint("uuid"), + ) diff --git a/superset/migrations/versions/2024-08-13_15-31_007a1abffe7e_remove_sl_tables.py b/superset/migrations/versions/2024-08-13_15-31_007a1abffe7e_remove_sl_tables.py new file mode 100644 index 0000000000000..bf5982572fd72 --- /dev/null +++ b/superset/migrations/versions/2024-08-13_15-31_007a1abffe7e_remove_sl_tables.py @@ -0,0 +1,72 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""remove sl_tables + +Revision ID: 007a1abffe7e +Revises: a6b32d2d07b1 +Create Date: 2024-08-13 15:31:31.478017 + +""" + +import sqlalchemy as sa +from alembic import op + +from superset.migrations.shared.constraints import drop_fks_for_table + +# revision identifiers, used by Alembic. +revision = "007a1abffe7e" +down_revision = "a6b32d2d07b1" + + +def upgrade(): + connection = op.get_bind() + if connection.dialect.name != "sqlite": + drop_fks_for_table("sl_tables") + op.drop_table("sl_tables") + + +def downgrade(): + op.create_table( + "sl_tables", + sa.Column("uuid", sa.Numeric(precision=16), nullable=True), + sa.Column("created_on", sa.DateTime(), nullable=True), + sa.Column("changed_on", sa.DateTime(), nullable=True), + sa.Column("id", sa.Integer(), nullable=False), + sa.Column("database_id", sa.Integer(), nullable=False), + sa.Column("is_managed_externally", sa.Boolean(), nullable=False), + sa.Column("catalog", sa.Text(), nullable=True), + sa.Column("schema", sa.Text(), nullable=True), + sa.Column("name", sa.Text(), nullable=True), + sa.Column("external_url", sa.Text(), nullable=True), + sa.Column("extra_json", sa.Text(), nullable=True), + sa.Column("created_by_fk", sa.Integer(), nullable=True), + sa.Column("changed_by_fk", sa.Integer(), nullable=True), + sa.ForeignKeyConstraint( + ["changed_by_fk"], + ["ab_user.id"], + ), + sa.ForeignKeyConstraint( + ["created_by_fk"], + ["ab_user.id"], + ), + sa.ForeignKeyConstraint( + ["database_id"], + ["dbs.id"], + ), + sa.PrimaryKeyConstraint("id"), + sa.UniqueConstraint("uuid"), + ) diff --git a/superset/migrations/versions/2024-08-13_15-33_48cbb571fa3a_remove_sl_datasets.py b/superset/migrations/versions/2024-08-13_15-33_48cbb571fa3a_remove_sl_datasets.py new file mode 100644 index 0000000000000..56598fc4d2228 --- /dev/null +++ b/superset/migrations/versions/2024-08-13_15-33_48cbb571fa3a_remove_sl_datasets.py @@ -0,0 +1,72 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""remove sl_datasets + +Revision ID: 48cbb571fa3a +Revises: 007a1abffe7e +Create Date: 2024-08-13 15:33:14.551012 + +""" + +import sqlalchemy as sa +from alembic import op + +from superset.migrations.shared.constraints import drop_fks_for_table + +# revision identifiers, used by Alembic. +revision = "48cbb571fa3a" +down_revision = "007a1abffe7e" + + +def upgrade(): + connection = op.get_bind() + if connection.dialect.name != "sqlite": + drop_fks_for_table("sl_datasets") + op.drop_table("sl_datasets") + + +def downgrade(): + op.create_table( + "sl_datasets", + sa.Column("uuid", sa.Numeric(precision=16), nullable=True), + sa.Column("created_on", sa.DateTime(), nullable=True), + sa.Column("changed_on", sa.DateTime(), nullable=True), + sa.Column("id", sa.Integer(), nullable=False), + sa.Column("database_id", sa.Integer(), nullable=False), + sa.Column("is_physical", sa.Boolean(), nullable=True), + sa.Column("is_managed_externally", sa.Boolean(), nullable=False), + sa.Column("name", sa.Text(), nullable=True), + sa.Column("expression", sa.Text(), nullable=True), + sa.Column("external_url", sa.Text(), nullable=True), + sa.Column("extra_json", sa.Text(), nullable=True), + sa.Column("created_by_fk", sa.Integer(), nullable=True), + sa.Column("changed_by_fk", sa.Integer(), nullable=True), + sa.ForeignKeyConstraint( + ["changed_by_fk"], + ["ab_user.id"], + ), + sa.ForeignKeyConstraint( + ["created_by_fk"], + ["ab_user.id"], + ), + sa.ForeignKeyConstraint( + ["database_id"], + ["dbs.id"], + ), + sa.PrimaryKeyConstraint("id"), + sa.UniqueConstraint("uuid"), + )