Repository navigation
I have a minor need to update migration checksums. Horrible idea? #4456
|
This is minor, and the instigator is not SQLx, but rather IDE tooling. That said, is it a terrible idea to update migration checksums after changing older migration files for reasons? Background is that I've bumped into an issue, that's mostly a stone in my shoe but absolutely will chafe soon: the Postgres Language Server project recently deprecated some lint suppressions. This means that after updating (I'm using Zed, it just came with a recent update I believe), I have warnings littering my migration code reminding me that the lints have been renamed, and the next major release will kill them and break suppressions. Nothing functional, nothing that breaks builds. Just diagnostic noise in my IDE. I'd like to update these migrations to fix the linter warnings now, but of course changing those files will cause the migration migration checksum mismatches. I could probably work around it with override/skip, with the only caveat that whenever I backed out to/before the override point, I'd have to issue the override again when moving forward. Rare enough to be manageable. I am curious though—the migration mechanism and specifically checksum verification looks simple enough that one could, if one were so inclined, just calculate new checksums and update the |
Replies: 1 comment 1 reply
|
It's a reasonable thing to do: the stored checksum is just the SHA-384 of the migration file's text, and sqlx only compares it with the UPDATE _sqlx_migrations SET checksum = decode('<hex>', 'hex') WHERE version = <version>;Do it in the same step that ships the edited files, and for every database including local dev ones, because a build with the old file contents will now hit the mismatch the other way round. |
It's a reasonable thing to do: the stored checksum is just the SHA-384 of the migration file's text, and sqlx only compares it with the
_sqlx_migrationsrow for that version, so after editing comments you can overwrite that row and nothing else will notice. The easiest way to get the exact value issqlx migrate info, which printslocal migration has checksum <hex>for every migration you edited, and then on Postgres:Do it in the same step that ships the edited files, and for every database including local dev ones, because a build with the old file contents will now hit the mismatch the other way round.