Expand description
Native replacement for cargo sqlx prepare, so a user of the framework
never needs sqlx-cli installed — just fse.
Mechanism (see sqlx-macros-core’s query/mod.rs): when a query!/
query_as!/query_scalar! call expands against a live DATABASE_URL
(i.e. not SQLX_OFFLINE=true), it writes its resolved metadata into
SQLX_OFFLINE_DIR as a side effect, if that env var points at an
existing directory. So all cargo sqlx prepare does — and all this
does — is: clear the old cache, force every query!-family call site to
re-expand (cargo’s fingerprinting has no way to know an env var changed,
so source files are touched to force it), and run cargo check --tests
with that env var set.
--tests (rather than a bare cargo check) matters because cfg(test)
is only enabled when checking test targets: integration tests under
tests/ are separate targets that a plain cargo check never builds at
all, and #[cfg(test)] unit-test modules inside src/ are compiled out
the same way. Either kind of query!-family call site — a fixture helper
in tests/common/mod.rs, or a #[cfg(test)] block in src/ — would
silently never run its capture side effect without it. So both src/
and tests/ need their .rs files touched, and cargo check needs
--tests to actually compile that code.