summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2024-11-03 10:16:52 -0500
committerOwen Jacobson <owen@grimoire.ca>2024-11-03 10:16:52 -0500
commita73821328fffd5a6bcbc28d9ac91e47806c56119 (patch)
tree6c114fb8bd56c6294db1809926dea9b29fc52384
parentdb01b7043b94d07e7e9a5131c235f0580ab967f0 (diff)
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.
-rw-r--r--.gitignore1
-rwxr-xr-xgit-hooks/pre-commit3
2 files changed, 4 insertions, 0 deletions
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