fix(migrations): replay user_favorite_tag migration for 3.0.x upgraders#38157
fix(migrations): replay user_favorite_tag migration for 3.0.x upgraders#38157
Conversation
Users upgrading from Superset 3.0.x to 4.0.x+ may have skipped migration e0f6f91c2055 (create_user_favorite_table) due to out-of-order migration timestamps. This caused the user_favorite_tag table to not be created, breaking the tag/favorite feature. Root cause: Migration e0f6f91c2055 (2023-07-12) depended on bf646a0c1501 (2023-06-28), whose down_revision a23c6f8b1280 was dated 2023-07-19. This temporal inconsistency caused Alembic to skip these migrations for users who had already applied the 3.0.1 head migration (4b85906e5b91). This replay migration safely re-runs the table creation using idempotent utilities. The create_table() function checks if the table exists before attempting creation, making this safe to run on all installations regardless of their upgrade history. Fixes #29836 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code Review Agent Run #29a0f8Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Sequence DiagramThis PR adds a replay Alembic migration that re-runs the original user_favorite_tag table creation safely. The sequence shows the upgrade command triggering the replay migration which delegates to the original migration module; the operation creates the table only if missing. sequenceDiagram
participant Operator
participant Alembic
participant ReplayMigration
participant OriginalMigration
participant Database
Operator->>Alembic: superset db upgrade
Alembic->>ReplayMigration: run a1b2c3d4e5f6 upgrade()
ReplayMigration->>OriginalMigration: import module & call module.upgrade()
OriginalMigration->>Database: create user_favorite_tag if not exists
Database-->>OriginalMigration: table created / already exists
OriginalMigration-->>ReplayMigration: upgrade complete
ReplayMigration-->>Alembic: migration complete
Generated by CodeAnt AI |
SUMMARY
This PR fixes a database migration issue affecting users who upgraded from Superset 3.0.x to 4.0.x+. The
user_favorite_tagtable was not being created during the upgrade, causing the tag/favorite feature to fail.Root Cause:
Migration
e0f6f91c2055(create_user_favorite_table, dated 2023-07-12) depended onbf646a0c1501(dated 2023-06-28), whosedown_revision(a23c6f8b1280) was dated 2023-07-19. This temporal inconsistency caused Alembic to skip these migrations for users who had already applied the 3.0.1 head migration.The Fix:
This PR adds a "replay" migration that re-runs the
user_favorite_tagtable creation using the idempotentcreate_table()utility. This is safe to run on all installations:This follows the established pattern from
b7851ee5522f_replay_317970b4400c.py.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A - This is a database migration fix with no UI changes.
TESTING INSTRUCTIONS
superset db upgrade- should complete successfullysuperset db upgrade- should log "Table user_favorite_tag already exists. Skipping..."superset db upgrade- should create the missing tableYou can verify the table exists with:
ADDITIONAL INFORMATION
CREATE TABLE IF NOT EXISTSequivalent🤖 Generated with Claude Code