betodealmeida opened a new pull request #15807: URL: https://github.com/apache/superset/pull/15807
### SUMMARY <!--- Describe the change below, including rationale and design decisions --> We're trying to run the `downgrade` from `49b5a32daba5_add_report_schedules.py`, but the migration errors because the unique constraint `uq_report_schedule_name` is not found. The `upgrade` function in the migration has the creation of the constraint inside a permissive `try/except` block, so I'm assuming the upgrade partially failed for some reason and now we can't downgrade. I modified the migration to check if the constraint exists before deleting it. The change should be harmless, because in theory the constraint should always exist. But maybe we should adopt this as a more conservative approach for `downgrade`s in migrations. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF <!--- Skip this if not applicable --> ### TESTING INSTRUCTIONS <!--- Required! What steps can be taken to manually verify the changes? --> I was able to benchmark the migration: ``` Identifying models used in the migration: - dbs (2 rows in table dbs) - slices (114 rows in table slices) - tables (27 rows in table tables) Benchmarking migration INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will assume transactional DDL. INFO [alembic.runtime.migration] Running upgrade f9a30386bd74 -> 620241d1153f, update time_grain_sqla Migration on current DB took: 0.25 seconds INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will assume transactional DDL. INFO [alembic.runtime.migration] Running downgrade 620241d1153f -> f9a30386bd74, update time_grain_sqla Running with at least 10 entities of each model - Adding 8 entities to the dbs model Processing ████████████████████████████████ 100% INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will assume transactional DDL. INFO [alembic.runtime.migration] Running upgrade f9a30386bd74 -> 620241d1153f, update time_grain_sqla Migration for 10+ entities took: 0.39 seconds INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will assume transactional DDL. INFO [alembic.runtime.migration] Running downgrade 620241d1153f -> f9a30386bd74, update time_grain_sqla Running with at least 100 entities of each model - Adding 90 entities to the dbs model Processing ████████████████████████████████ 100% - Adding 73 entities to the tables model Processing ████████████████████████████████ 100% INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will assume transactional DDL. INFO [alembic.runtime.migration] Running upgrade f9a30386bd74 -> 620241d1153f, update time_grain_sqla Migration for 100+ entities took: 0.38 seconds INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will assume transactional DDL. INFO [alembic.runtime.migration] Running downgrade 620241d1153f -> f9a30386bd74, update time_grain_sqla Running with at least 1000 entities of each model - Adding 900 entities to the dbs model Processing ████████████████████████████████ 100% - Adding 886 entities to the slices model Processing ████████████████████████████████ 100% - Adding 900 entities to the tables model Processing ████████████████████████████████ 100% INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will assume transactional DDL. INFO [alembic.runtime.migration] Running upgrade f9a30386bd74 -> 620241d1153f, update time_grain_sqla Migration for 1000+ entities took: 0.31 seconds Cleaning up DB Revert DB to 620241d1153f? [y/N]: y INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will assume transactional DDL. Reverted Results: Current: 0.25 s 10+: 0.39 s 100+: 0.38 s 1000+: 0.31 s ``` ### ADDITIONAL INFORMATION <!--- Check any relevant boxes with "x" --> <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue --> - [ ] Has associated issue: - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [ ] Introduces new feature or API - [ ] Removes existing feature or API -- 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]
