diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eb17abf..ebe63fd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -44,6 +44,18 @@ repos: language: system types: [nix] exclude: extra + - id: sqlx + name: SQLX Database up-to-date + entry: >- + bash -euo pipefail -c 'DB_URL="sqlite://./opsqueue/opsqueue_example_database_schema.db"; + if [[ -f ./opsqueue/opsqueue_example_database_schema.db ]]; then + sqlx migrate run --database-url "$DB_URL" --source ./migrations; + else + sqlx database setup --database-url "$DB_URL" --source ./migrations; + fi' + language: system + files: ^(migrations|opsqueue/migrations)/.*\.sql$ + pass_filenames: false - id: sqlx-test-needs-migrator name: Require `#[sqlx::test(migrator = "crate::MIGRATOR")]` for test-build speed entry: '#\[sqlx::test\]' diff --git a/default.nix b/default.nix index 2da1a73..d8facc3 100644 --- a/default.nix +++ b/default.nix @@ -32,6 +32,7 @@ let pkgs.biome pkgs.nixfmt pkgs.pre-commit + pkgs.python3Packages.identify pkgs.python3Packages.pre-commit-hooks pkgs.ruff pkgs.typos diff --git a/opsqueue/opsqueue_example_database_schema.db b/opsqueue/opsqueue_example_database_schema.db index ae49303..83e0994 100644 Binary files a/opsqueue/opsqueue_example_database_schema.db and b/opsqueue/opsqueue_example_database_schema.db differ