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

Update migrations.py #112

Merged
merged 1 commit into from
Aug 9, 2023
Merged

Conversation

antoonhuiskens
Copy link
Contributor

@antoonhuiskens antoonhuiskens commented Jul 13, 2023

Added "IF EXISTS" to the DROP CONSTRAINT statement intending to drop the {LTSS.tablename}_pkey.

I've opened issue #111 for tracking this.

DROP CONSTRAINT IF EXISTS capability exists in PostgreSQL versions going back to at least version 11 (oldest supported version by postgreSQL)

Tested this against postgreSQL 15.

@Coffee0297
Copy link

Can confirm this works with the missing table when dropping. tested with latest version of LTSS

@freol35241
Copy link
Owner

Thank you @antoonhuiskens . This looks reasonable, however it would be good to try to understand why this is necessary. Do you have any idea?

This is also related to the (OT?) discussion in #100

@antoonhuiskens
Copy link
Contributor Author

I suspect I had a few passes at installing due to backing out the upgrade and down revving to the previous version in order to get things working again. Looking at the code, it seems reasonable to assume that caused the initial deletion of the key.

Since this is a distinct issue unrelated to compression as per #100, I figured it would be helpful to create a separate issue and fix.
/A

@antoonhuiskens
Copy link
Contributor Author

antoonhuiskens commented Jul 25, 2023

A more general approach would likely be to wrap the entire set of upgrade changes to the db in a a BEGIN/COMMIT block, with a ROLLBACK in case of errors, so a robust way would be to autocommit=False for all sql, plus some code to handle the commit. Out of scope for this PR though.

That should (in theory) prevent the db from getting into an undefined state.

Added "IF EXISTS" to the DROP CONSTRAINT statement intending to drop the {LTSS.__tablename__}_pkey.
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.

constraint "ltss_pkey" of relation "ltss" does not exist causes migration to fail to v.2.1.0
3 participants