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

Safely Downgrade Bug Fix #2182

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

P0NDER0SA
Copy link
Contributor

Summary | Résumé

Fixing a bug that fails on downgrade. This will allow this migration to safely upgrade and downgrade without problems

Test instructions | Instructions pour tester la modification

run Flask db downgrades and upgrades that would affect this migration. ensure all is well in the world.

Fixing a bug that fails on downgrade.  This will allow this migration to safely upgrade and downgrade without problems
@P0NDER0SA P0NDER0SA requested a review from patheard May 28, 2024 19:55
P0NDER0SA and others added 2 commits May 28, 2024 16:02
Yep, This works -- Thanks Pat!

Co-authored-by: Pat Heard <patrick.heard@cds-snc.ca>
patheard
patheard previously approved these changes May 28, 2024
Copy link
Member

@patheard patheard left a comment

Choose a reason for hiding this comment

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

As discussed, makes sense not to perform the REVOKE in the downgrade because of the chaos this would cause as the API relies on the app_db_user to run its migrations.

After further discussions with the team, we have decided that we should make our downgrades more representative of a reversal of what an upgrade does, but while also safely been tested for upgrade and downgrade paths
@P0NDER0SA P0NDER0SA requested review from jimleroyer, a team and sastels and removed request for a team May 29, 2024 17:30
@P0NDER0SA
Copy link
Contributor Author

@patheard @jimleroyer @sastels -- Might be worth having a conversation about this. I think the idea here is that if we downgrade and then upgrade this would be done as a more manual process for now, and only as necessary. I think @jimleroyer and @sastels would prefer to try and focus on doing a more representative 'downgrade' that we test thoroughly as a downgrade and upgrade before we merge these. There are historically many that will break if you do that process.

@P0NDER0SA P0NDER0SA requested a review from patheard May 29, 2024 18:01
@P0NDER0SA P0NDER0SA dismissed patheard’s stale review May 29, 2024 18:02

made some changes and looking for a bit of conversation with new reviewers

@sastels
Copy link
Collaborator

sastels commented May 29, 2024

As discussed, makes sense not to perform the REVOKE in the downgrade because of the chaos this would cause as the API relies on the app_db_user to run its migrations.

Are we sure about this? we just run

flask db upgrade

here. I was assuming it was the postgres user or some other flask magic? app_db_user was just added when we started using blazer afaik.

@jimleroyer
Copy link
Member

It's true we are using that user to connect with the app though, not just for blazer, as I think you standardized it @sastels (or Pat?).

@sastels
Copy link
Collaborator

sastels commented May 29, 2024

It's true we are using that user to connect with the app though, not just for blazer, as I think you standardized it @sastels (or Pat?).

oh, 💯 the app would horribly break, but I didn't think flask would. unless flask is magically using POSTGRES_SQL or SQLALCHEMY_DATABASE_READER_URI - which it could be.

Update: ok, here's the relevant code. We set the flask variable SQLALCHEMY_DATABASE_URI from POSTGRES_SQL, which we set in the .env file and use app_db_user.

@P0NDER0SA
Copy link
Contributor Author

Just another bit of reassurance on this -- this was tested 100% on dev and the upgrade and downgrade paths were working well. Very very low risk to merge this. We could always try a scenario on staging to see how it reacts in the future.

@jimleroyer
Copy link
Member

@sastels Yes, the app, which is a Flask app, uses the values in the .env files. I am not sure which other DB connection config the app would leverage otherwise.

@sastels
Copy link
Collaborator

sastels commented May 29, 2024

Just another bit of reassurance on this -- this was tested 100% on dev and the upgrade and downgrade paths were working well. Very very low risk to merge this. We could always try a scenario on staging to see how it reacts in the future.

dev is just using the postgres user for everything though (well, for the flask stuff?) because we were to lazy to figure out a programatic way to create the app_user 😞

@jimleroyer
Copy link
Member

We talked offline and decided that this user is good for connecting to our app but we will have the admin one to bootstrap the schemas and take in charge the alembic upgrades. This user would be created by Terraform when booting up a new environment. A related task card was created and will be refined for this purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants