-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add functions that let you do pre- and post- auto-migration hooks that run in the same transaction #50
Open
cgibbard
wants to merge
19
commits into
develop
Choose a base branch
from
cg/pre-post-hooks
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Table constraints are now keyed according to what they constrain instead of all of their attributes, including names. No "type of all constraints, one at a time". separate types for PRIMARY KEY, UNIQUE, and FOREIGN KEY constraints; all split into the "match" and "extra" parts. All such constraints are now collected into a record of maps, with the key being the match part of that constraint type and all other data in the value of the map. In most places for constraint/sequence, the name is wrapped in a Maybe, to instruct beam-automigrate to allow postgres to choose the name, or use the name from the db for existing, matching entity. Sequences are now (optionally) owned by "SERIAL" columns using the built in "OWNED BY" syntax in postgres. A serial column can have an optional name; beam-migrate will learn the name chosen by postgres at startup when it already exists. string parsing of DEFAULT constraints are now handled with a self contained attoparsec based parser in `D.B.A.Parser`. It's only parsing the fragment of sql that beam-automigrate needs to understand to do it's job; but is a good start for gradually improving its precision as the need arises (future check-constraint support, as an example) More liberal use of `"lens"` library to make some code a little easier to understand. Fixes dodgy catalog sql query for retrieving foreign key constraints. how did this ever work?
… as soon as it was added
Before ("NULLDEFAULT"): CREATE TABLE cities (capital BOOL NOT NULLDEFAULT 'false'::boolean, city VARCHAR NOT NULL, location VARCHAR NOT NULL); After: CREATE TABLE cities (capital BOOL NOT NULL DEFAULT 'false'::boolean, city VARCHAR NOT NULL , location VARCHAR NOT NULL );
Previous commits introduce a bug where no migration is assumed if both versions of a table have a primary key at all, This commit fixes the case when both versions have a PK but with different columns. This also exposed a related bug that primary key migrations must be handled differently to unique key migrations. a table can have only one PK, which has further affects on when foreign key constraints must be added or removed.
Otherwise, SequenceSetOwner will be executed on the new name before it has been renamed
…de the same transaction
Namely runMigrationWithEditUpdateAndHooksDryRun and tryRunMigrationsWithEditUpdateAndHooksDryRun
…ctions As the function name implies, the functions that start with "tryRunMigrationsWithEditUpdate" should take an "editUpdate" argument -- just like their "runMigrationWithEditUpdate"-counterparts.
…utomigrate into cg/pre-post-hooks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.