From a73821328fffd5a6bcbc28d9ac91e47806c56119 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Sun, 3 Nov 2024 10:16:52 -0500 Subject: Verify .sqlx files against an empty DB. For reasons beyond my understanding, the `sqlx prepare` command produces different results for sqlite depending on whether there are or are not rows in certain tables. This ensures that the files are generated consistently with an _empty_ database. --- git-hooks/pre-commit | 3 +++ 1 file changed, 3 insertions(+) (limited to 'git-hooks') diff --git a/git-hooks/pre-commit b/git-hooks/pre-commit index 22c5dfe..6715430 100755 --- a/git-hooks/pre-commit +++ b/git-hooks/pre-commit @@ -13,4 +13,7 @@ npm run lint cargo check # Make sure the prepared statement data in .sqlx is up to date. Requires # `cargo-sqlx` (`cargo install cargo-sqlx`). +export DATABASE_URL=sqlite://.hi.pre-commit?mode=rwc +rm -f .hi.pre-commit +cargo sqlx migrate run cargo sqlx prepare --check -- cgit v1.2.3