-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: use golang migrate #1504
base: v3
Are you sure you want to change the base?
feat: use golang migrate #1504
Conversation
a09ff0c
to
e38d434
Compare
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.
nice work, left some comments
} | ||
} | ||
|
||
atomic.StoreUint32(&d.migrated, 1) |
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.
why don't we also check this flag at the start of the Migrate
method?
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 could, but we didn't before so I haven't changed that logic.
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.
i guess it's uncommon we call the Migrate
twice in our tests, because we usually create a new db for each test.
internal/dbmodel/sql/postgres/005_add_migrating_controller_column.up.sql
Outdated
Show resolved
Hide resolved
9232343
to
e404e1c
Compare
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.
lgtm
Description
This PR removes our home-grown migration code in favour of golang-migrate.
Some reservations I had with Golang-migrate over Goose and why I'm okay with it now:
I recommend reviewing this PR commit-by-commit to more easily see the changes.
The benefits this gives us aren't huge. One benefit is that we don't need to modify the versions.go file when we add a new migration file, it will just automatically be applied, leaving less room for error.
Fixes JUJU-7047
Engineering checklist
Test instructions
To test the new migrations on a fresh DB, just
docker compose --profile dev up
.To test migrations on a DB that was using the old-style migrations. Switch to the
v3
branch then ``docker compose --profile dev up` then switch to this branch and observe the jimm logs.