Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Migration order due to cherry which went astray #26160

Merged
merged 1 commit into from
Dec 2, 2023

Conversation

john-bodley
Copy link
Member

@john-bodley john-bodley commented Dec 1, 2023

SUMMARY

This PR fixes a Alembic migration conundrum when upgrading from 3.0 to 3.1 due to a picked cherry which somehow went astray.

The Alembic visions chain on the various branches is:

master

  • ec54aca4c8a2
  • 317970b4400c
  • 4b85906e5b91

3.0

  • ec54aca4c8a2
  • 4b85906e5b91

3.1

  • ec54aca4c8a2
  • 317970b4400c
  • 4b85906e5b91

i.e., per the previously mentioned cherry in 3.0 revision 4b85906e5b91 somehow became rewired from 317970b4400c to ec54aca4c8a2 meaning the 317970b4400c was never present in 3.0.

This PR:

  1. Adds safeguards to 317970b4400c.
  2. Adds revision b7851ee5522f—which should also be cherry-picked into 3.1—which merely replays 317970b4400c for both master and 3.1.

These two steps ensure that if your upgrading/downgrading from either master or 3.0 that 317970b4400c will run if and only if the migration has not been run previous—determined by the presence/absence of the column respectively.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

CI.

ADDITIONAL INFORMATION

@john-bodley john-bodley requested a review from a team as a code owner December 1, 2023 20:25
@john-bodley john-bodley added the v3.1 Label added by the release manager to track PRs to be included in the 3.1 branch label Dec 1, 2023
Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

codecov bot commented Dec 1, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (1b9e4ff) 69.20% compared to head (e05e760) 69.20%.

Files Patch % Lines
superset/migrations/shared/utils.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #26160   +/-   ##
=======================================
  Coverage   69.20%   69.20%           
=======================================
  Files        1941     1941           
  Lines       75906    75904    -2     
  Branches     8457     8457           
=======================================
  Hits        52533    52533           
+ Misses      21177    21175    -2     
  Partials     2196     2196           
Flag Coverage Δ
hive 53.68% <0.00%> (+<0.01%) ⬆️
mysql 78.16% <0.00%> (+<0.01%) ⬆️
postgres 78.26% <0.00%> (+<0.01%) ⬆️
presto 53.63% <0.00%> (+<0.01%) ⬆️
python 82.95% <0.00%> (+<0.01%) ⬆️
sqlite 76.91% <0.00%> (+<0.01%) ⬆️
unit 55.79% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

)
insp = reflection.Inspector.from_engine(engine)

insp = inspect(op.get_context().bind)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The table_has_column method was returning False for PostgreSQL within CI even though the columns existed. The proposed update is from the same Stack Overflow post, however it's from 2022 (as opposed to 2018) and has more votes.

@eschutho
Copy link
Member

eschutho commented Dec 1, 2023

Thanks @john-bodley, this looks good to me too. I outlined what the "after" would look like as I was reading through this, so pasting it here for anyone else interested. (pls correct me if I missed anything)

master

  • ec54aca4c8a2
  • 317970b4400c
  • 4b85906e5b91
  • b7851ee5522f (replays 317970b4400c)

3.0

  • ec54aca4c8a2
  • 4b85906e5b91

3.1.0

  • ec54aca4c8a2
  • 317970b4400c (won't run if 3.0 migration has already happened)
  • 4b85906e5b91

3.1.1

  • ec54aca4c8a2
  • 317970b4400c (won't run if 3.0 migration has already happened)
  • 4b85906e5b91
  • b7851ee5522f (replays 317970b4400c if it hasn't already run, otherwise, it will skip)

@john-bodley
Copy link
Member Author

Thanks @eschutho for adding this—I was wondering whether I should have added something similar. I did update your comment to include b7851ee5522f in 3.1. We likely could just remove the 3.1.x section as well.

@john-bodley john-bodley merged commit 8644b1a into apache:master Dec 2, 2023
43 checks passed
@john-bodley john-bodley deleted the john-bodley--fix-migration branch December 2, 2023 02:29
michael-s-molina pushed a commit that referenced this pull request Dec 4, 2023
@eschutho
Copy link
Member

eschutho commented Dec 4, 2023

Great, I updated the comment for anyone else reading this, edited it to 3.1.0 specifically so we can see where it was added in later, and I showed where the 317970b4400c wouldn't run. lmk if that comment makes more sense, or feel free to edit.

john-bodley added a commit to john-bodley/superset that referenced this pull request Jan 17, 2024
josedev-union pushed a commit to Ortege-xyz/studio that referenced this pull request Jan 22, 2024
@mistercrunch mistercrunch added 🍒 3.1.0 🍒 3.1.1 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels labels Mar 8, 2024
sfirke pushed a commit to sfirke/superset that referenced this pull request Mar 22, 2024
vinothkumar66 pushed a commit to vinothkumar66/superset that referenced this pull request Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/M v3.1 Label added by the release manager to track PRs to be included in the 3.1 branch 🍒 3.1.0 🍒 3.1.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants