sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

Warnings for .down.sql checksums

Open alextes opened this issue 2 years ago • 2 comments

It appears using down migrations and then running sqlx migrate info results in various unhappy logs that complain a checksum with a matching version is installed, but with the wrong checksum. If I understand correctly this is because up and down migrations share a version and the checksum only matches the up migration.

Does that sound right? and if yes, should we change it to get rid of the "seemingly something is wrong, but not really".

I imagine options are:

  1. ignore down migrations, they're not being checksummed and haven't actually modified the DB as they haven't run, so don't check if they match either.

  2. add down migrations to the migrations table. (might result in odd behavior as they haven't actually been run)

  3. use a whole separate table, or column to identify down migrations, with their checksums, allowing to check they haven't been changed whilst still easily allowing to update them considering they haven't been run or whatever other behavior they need.

  4. sounds most sensible to me.

alextes avatar Jun 28 '22 08:06 alextes

A screenshot to illustrate what the warnings look like. Do note some warnings might look valid because I tried to fix the checksums by hand by updating the checksum misunderstanding that the warning was valid for some but invalid for others.

Screenshot 2022-06-28 at 12 15 30

alextes avatar Jun 28 '22 09:06 alextes

I'd like to work on this but not sure where to get started, how about the simplest, a PR for 1. that makes it easiest to later change our minds and alleviates the direct problem without doing anything more.

That is, if a migration ends in .down.sql it is not considered for checksum comparison.

How does that sound?

alextes avatar Aug 27 '22 08:08 alextes