sadpandajoe commented on code in PR #44362:
URL: https://github.com/apache/superset/pull/44362#discussion_r4169750744


##########
superset/migrations/versions/2026-09-16_00-01_00fab727cd0a_add_theme_editors_theme_id_index.py:
##########
@@ -0,0 +1,64 @@
+# 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.
+"""add theme_editors.theme_id index
+
+Revision ID: 00fab727cd0a
+Revises: 95d8a99c822e
+Create Date: 2026-09-16 00:01:00.000000
+
+"""
+
+from alembic import op
+from sqlalchemy.dialects.mysql.base import MySQLDialect
+
+from superset.migrations.shared.utils import create_index, drop_index
+
+# revision identifiers, used by Alembic.
+revision = "00fab727cd0a"
+down_revision = "95d8a99c822e"
+
+TABLE_NAME = "theme_editors"
+INDEX_NAME = "ix_theme_editors_theme_id"
+
+
+def _is_mysql() -> bool:
+    return isinstance(op.get_bind().dialect, MySQLDialect)
+
+
+def upgrade() -> None:
+    """Add an index on theme_editors.theme_id."""
+    # theme_editors' only index is the UNIQUE(subject_id, theme_id) constraint
+    # from its creation (#42404), which leads with subject_id -- most engines
+    # can't use a composite index to serve a lookup filtered on its trailing
+    # column alone. Loading a theme's editor list filters on theme_id only,
+    # so that's a table scan on every load without a dedicated index.
+    #
+    # MySQL is the exception: InnoDB auto-creates a single-column index on
+    # theme_id to support the theme_id foreign key, so the lookup is already
+    # indexed there and this index would just duplicate it.
+    if _is_mysql():

Review Comment:
   A regression in either MySQL guard could reintroduce the rollback failure 
without automated detection; `test_add_theme_editors.py` only exercises the 
predecessor revision. Could a migration test use the real MySQL dialect and 
assert that both upgrade and downgrade call neither DDL helper, with a SQLite 
round trip checking index creation and removal?



##########
superset/migrations/versions/2026-09-16_00-01_00fab727cd0a_add_theme_editors_theme_id_index.py:
##########
@@ -0,0 +1,47 @@
+# 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.
+"""add theme_editors.theme_id index
+
+Revision ID: 00fab727cd0a
+Revises: 60f94cd6cd11
+Create Date: 2026-09-16 00:01:00.000000
+
+"""
+
+from superset.migrations.shared.utils import create_index, drop_index
+
+# revision identifiers, used by Alembic.
+revision = "00fab727cd0a"
+down_revision = "60f94cd6cd11"

Review Comment:
   Current `master` now has `884a2115ebd3`, also descending from 
`95d8a99c822e`, so this migration would again create two Alembic heads and 
block `superset db upgrade` after merging. Could its parent be updated to the 
current head?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to