You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2024/08/09 18:12:02 UTC

(superset) branch master updated: fix: Error when downgrading add_catalog_perm_to_tables migration (#29906)

This is an automated email from the ASF dual-hosted git repository.

michaelsmolina pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new fb7f50868d fix: Error when downgrading add_catalog_perm_to_tables migration (#29906)
fb7f50868d is described below

commit fb7f50868df99b9d42e611a7f1b7fb5a70d4eab0
Author: Michael S. Molina <70...@users.noreply.github.com>
AuthorDate: Fri Aug 9 14:11:55 2024 -0400

    fix: Error when downgrading add_catalog_perm_to_tables migration (#29906)
---
 ...-04-11_15-41_5f57af97bc3f_add_catalog_column.py | 28 +++++++---------------
 ...0-52_58d051681a3b_add_catalog_perm_to_tables.py |  2 +-
 2 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/superset/migrations/versions/2024-04-11_15-41_5f57af97bc3f_add_catalog_column.py b/superset/migrations/versions/2024-04-11_15-41_5f57af97bc3f_add_catalog_column.py
index ec5733e151..7ed95324dd 100644
--- a/superset/migrations/versions/2024-04-11_15-41_5f57af97bc3f_add_catalog_column.py
+++ b/superset/migrations/versions/2024-04-11_15-41_5f57af97bc3f_add_catalog_column.py
@@ -29,27 +29,17 @@ from alembic import op
 revision = "5f57af97bc3f"
 down_revision = "d60591c5515f"
 
+tables = ["tables", "query", "saved_query", "tab_state", "table_schema"]
+
 
 def upgrade():
-    op.add_column("tables", sa.Column("catalog", sa.String(length=256), nullable=True))
-    op.add_column("query", sa.Column("catalog", sa.String(length=256), nullable=True))
-    op.add_column(
-        "saved_query",
-        sa.Column("catalog", sa.String(length=256), nullable=True),
-    )
-    op.add_column(
-        "tab_state",
-        sa.Column("catalog", sa.String(length=256), nullable=True),
-    )
-    op.add_column(
-        "table_schema",
-        sa.Column("catalog", sa.String(length=256), nullable=True),
-    )
+    for table in tables:
+        op.add_column(
+            table,
+            sa.Column("catalog", sa.String(length=256), nullable=True),
+        )
 
 
 def downgrade():
-    op.drop_column("table_schema", "catalog")
-    op.drop_column("tab_state", "catalog")
-    op.drop_column("saved_query", "catalog")
-    op.drop_column("query", "catalog")
-    op.drop_column("tables", "catalog")
+    for table in reversed(tables):
+        op.drop_column(table, "catalog")
diff --git a/superset/migrations/versions/2024-05-01_10-52_58d051681a3b_add_catalog_perm_to_tables.py b/superset/migrations/versions/2024-05-01_10-52_58d051681a3b_add_catalog_perm_to_tables.py
index 856ad2ad03..88b3d63527 100644
--- a/superset/migrations/versions/2024-05-01_10-52_58d051681a3b_add_catalog_perm_to_tables.py
+++ b/superset/migrations/versions/2024-05-01_10-52_58d051681a3b_add_catalog_perm_to_tables.py
@@ -48,6 +48,6 @@ def upgrade():
 
 
 def downgrade():
+    downgrade_catalog_perms(engines={"postgresql"})
     op.drop_column("slices", "catalog_perm")
     op.drop_column("tables", "catalog_perm")
-    downgrade_catalog_perms(engines={"postgresql"})