-
Notifications
You must be signed in to change notification settings - Fork 124
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
tapdb: fix multiple issues around migration file handling #1089
Conversation
This commit adds a check script to our CI that makes sure there are no "holes" in the numbering of our migration version files. The script would also detect duplicate numbers in the migration prefixes. This is to prevent mistakes from cherry-picking commits onto branches that contain migration files.
Pull Request Test Coverage Report for Build 10406480087Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
b38865f
to
1e3feb3
Compare
Due to a git branch cherry-pick mishap, the migration number 14 wasn't included in a released version and therefore wasn't applied on some systems. Because the tables in that migration file were only being used with a recently released version (v0.4.0/v0.4.1), this wasn't noticed for a long time. We fix this by re-applying the same migration as number 23, slightly modified so that it's a no-op if the tables and entries already exist on a system.
1e3feb3
to
1826364
Compare
Our SQL scripts on disk were neither SQLite nor Postgres compatible, we used a version suited for sqlc to generate the correct data types we wanted, then did some type replacements in-memory when actually applying the migration files. This is somewhat dangerous as it will lead to situations where if a user applies a migration file manually, they'll end up with table primary keys that ARE NOT auto incrementing. To fix this issue, we make sure that we always write fully SQLite compatible SQL code and only apply fixes for the sqlc code generation directly before generating the code.
1826364
to
17ae210
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.
Looks good 👍 I've tested the script locally on Linux.
Another fee estimation itest here:
I will re-run the job. |
Maybe we need to enable the docker image cache, since we pull a new Postgres image every time we run the CI with docker... |
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!
Tested the script with a fake migration of prefix 000025
, both only with up
and up
/down
.
Also checked on the BIGINT PRIMARY KEY
-> INTEGER PRIMARY KEY
replacement, and that BIGSERIAL
is the right Postgres type to use here.
Going to verify the postgres itest suceeds locally before merging. I'm also going to build a |
Applied this to my node without problems and also ran the full postgres itest locally. |
Fixes #1071.
This PR is the result after almost two days of debugging #1071.
The TL;DR is: due to a git branch cherry-pick mishap, the migration number 14 wasn't included in the
v0.3.3
release version. Some users then applied the migration directly as it was in the source directory, which lead to them not having properly working auto incrementing primary keys.The first commit in this PR adds a CI check that verifies migration numbers in the file names are continuous.
The second commit re-applies the migration 14 (somewhat modified) as migration 23.
The last commit then fixes the workaround with the primary key type replacements we used. See comment in
scripts/gen_sqlc_docker.sh
if you want to understand the full problem and solution.