Skip to content

Comments

fix(migrations): replay user_favorite_tag migration for 3.0.x upgraders#38157

Open
rusackas wants to merge 1 commit intomasterfrom
fix/replay-user-favorite-tag-migration-29836
Open

fix(migrations): replay user_favorite_tag migration for 3.0.x upgraders#38157
rusackas wants to merge 1 commit intomasterfrom
fix/replay-user-favorite-tag-migration-29836

Conversation

@rusackas
Copy link
Member

SUMMARY

This PR fixes a database migration issue affecting users who upgraded from Superset 3.0.x to 4.0.x+. The user_favorite_tag table 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 on bf646a0c1501 (dated 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.

The Fix:
This PR adds a "replay" migration that re-runs the user_favorite_tag table creation using the idempotent create_table() utility. This is safe to run on all installations:

  • If the table doesn't exist → it gets created
  • If the table already exists → the migration is skipped with an informational log message

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

  1. For fresh installs: Run superset db upgrade - should complete successfully
  2. For existing installs with the table: Run superset db upgrade - should log "Table user_favorite_tag already exists. Skipping..."
  3. For affected 3.0.x upgraders: Run superset db upgrade - should create the missing table

You can verify the table exists with:

SELECT * FROM information_schema.tables WHERE table_name = 'user_favorite_tag';

ADDITIONAL INFORMATION

🤖 Generated with Claude Code

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>
@dosubot
Copy link

dosubot bot commented Feb 22, 2026

Related Documentation

Checked 0 published document(s) in 2 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@github-actions github-actions bot added the risk:db-migration PRs that require a DB migration label Feb 22, 2026
@bito-code-review
Copy link
Contributor

bito-code-review bot commented Feb 22, 2026

Code Review Agent Run #29a0f8

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: f8acbf2..f8acbf2
    • superset/migrations/versions/2026-02-21_22-00_a1b2c3d4e5f6_replay_user_favorite_tag_migration.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@codeant-ai-for-open-source
Copy link
Contributor

Sequence Diagram

This 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
Loading

Generated by CodeAnt AI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:backend Requires changing the backend risk:db-migration PRs that require a DB migration size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"user_favorite_tag" table not created after "superset db upgrade" when upgrade superset 3.0.1 to 4.0.2 on docker

1 participant