-
Notifications
You must be signed in to change notification settings - Fork 292
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
Organize DB Schema Migration Code and DB Init Checks #842
Merged
Merged
Changes from 29 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
b4e7a9b
Create Schema Manager and propagate contexts into the DB calls downst…
talanknight add34f1
Add tests for schema manager library.
talanknight 4e198d4
Check schema state before starting server and when running init.
talanknight 1d38834
Fixing overflowed SchemaAccessLockid.
talanknight ce20fca
Merge remote-tracking branch 'origin/main' into toddknight-schema-man…
talanknight 3a05502
Reorganize the directory structure around schema migrations and manag…
talanknight 890a9a1
Pull in some files from golang-migrations.
talanknight a595122
Merge remote-tracking branch 'origin/main' into toddknight-schema-man…
talanknight 50ed3db
Add boundary domain errors and unexport functions that don't need to …
talanknight 5039d42
Adding comments and and organizing tests for the schema directory.
talanknight 8c8debc
Add test for migrating up from an existing initialized db.
talanknight a6994c1
Fixing error formatting error for the SharedLock and ExclusiveLock me…
talanknight 1c1e0a2
Merge remote-tracking branch 'origin/main' into toddknight-schema-man…
talanknight 0cb5c43
Init now checks for a previous bad initialization.
talanknight 5f607c7
Adding tests for the new migration related error codes.
talanknight 4c90aa6
Merge remote-tracking branch 'origin/main' into toddknight-schema-man…
talanknight a18f9b4
Merge remote-tracking branch 'origin/main' into toddknight-schema-man…
talanknight f5dbf8c
Schema manager now use's driver for db locking. Renamed and moved som…
talanknight 85a95ce
Moved postgres interfacing specific logic to its own package and defi…
talanknight 5acf2f9
Merge branch 'main' into toddknight-schema-management
talanknight cedc3a9
Fix int overflow for 386 platforms.
talanknight 4d4e310
Adding tests and comments.
talanknight b6981cd
Merge remote-tracking branch 'origin/main' into toddknight-schema-man…
talanknight 3243c92
Update internal/cmd/commands/database/init.go
talanknight 790a1a1
Update internal/cmd/commands/database/init.go
talanknight c7ac37e
Adding context to server command.
talanknight 8eb2c36
Set up `server` and `dev` commands to use a context created when the …
talanknight 398cbe6
Passing context into CreateDevDatabase.
talanknight f8a450d
Passing context into CreateDevDatabase.
talanknight 5722661
Fix comments and some variable naming.
talanknight 793a428
stop exporting a number of test helper functions.
talanknight 8af94f1
Explicitly release any locks the commands have captured.
talanknight 7d0d784
Adding README to migrations directory.
talanknight a8f553c
Merge remote-tracking branch 'origin/main' into toddknight-schema-man…
talanknight File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,7 +78,7 @@ perms-table: | |
gen: cleangen proto api migrations fmt | ||
|
||
migrations: | ||
$(MAKE) --environment-overrides -C internal/db/migrations/genmigrations migrations | ||
$(MAKE) --environment-overrides -C internal/db/schema/migrations/generate migrations | ||
|
||
### oplog requires protoc-gen-go v1.20.0 or later | ||
# GO111MODULE=on go get -u github.com/golang/protobuf/[email protected] | ||
|
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
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, when would this happen, vs. the transaction containing the migration rolling back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We currently never rollback. If there is an error we stop where it failed and leave the dirty bit set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't the transaction failing cause the changes from that migration to roll back? Isn't each migration its own transaction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct, but that is only because the content of the migration issued the rollback and not because the migration library itself enforces it. This does get close to a topic I plan on trying to fix soon. When we fail after the the schema update has completed successfully but before all the default resources are created. IMO we should still mark the migration as being in a dirty state. Maybe the solution is pulling the dirty bit out to be managed through an interface in the schema manager so the caller can decide if the migration is
dirty
or not. I'm happy to talk more about this face to face or on slack.