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 index 7f87040a5da61..745da474a2a57 100644 --- 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 @@ -41,35 +41,21 @@ def upgrade(): 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"), - ) 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.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"], @@ -87,19 +73,19 @@ 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.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"], @@ -116,23 +102,61 @@ def downgrade(): sa.UniqueConstraint("uuid"), ) op.create_table( - "sl_dataset_columns", - sa.Column("dataset_id", sa.INTEGER(), nullable=False), - sa.Column("column_id", sa.INTEGER(), nullable=False), + "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( - ["column_id"], - ["sl_columns.id"], + ["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.PrimaryKeyConstraint("dataset_id", "column_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.Column("dataset_id", sa.Integer(), nullable=False), + sa.Column("table_id", sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ["dataset_id"], ["sl_datasets.id"], @@ -145,8 +169,8 @@ 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.Column("table_id", sa.Integer(), nullable=False), + sa.Column("column_id", sa.Integer(), nullable=False), sa.ForeignKeyConstraint( ["column_id"], ["sl_columns.id"], @@ -158,40 +182,16 @@ def downgrade(): sa.PrimaryKeyConstraint("table_id", "column_id"), ) 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), + "sl_dataset_columns", + sa.Column("dataset_id", sa.Integer(), nullable=False), + sa.Column("column_id", sa.Integer(), nullable=False), sa.ForeignKeyConstraint( - ["changed_by_fk"], - ["ab_user.id"], + ["column_id"], + ["sl_columns.id"], ), sa.ForeignKeyConstraint( - ["created_by_fk"], - ["ab_user.id"], + ["dataset_id"], + ["sl_datasets.id"], ), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("uuid"), + sa.PrimaryKeyConstraint("dataset_id", "column_id"), )