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. --- .gitignore | 1 + git-hooks/pre-commit | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index fef82d6..7977b18 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /node_modules /target /.hi +/.hi.pre-commit /.hi.backup /vite.config.js.*.mjs 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