Last active
February 22, 2022 23:27
-
-
Save ivan/7532c95c323d985dbbaa786a3a08c80f to your computer and use it in GitHub Desktop.
An alternative to `cargo sqlx prepare --merged` that doesn't rebuild all the crates in the workspace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| set -eu -o pipefail | |
| export DATABASE_URL=$(pg_tmp) | |
| psql "$DATABASE_URL" -f schema/schema.sql | |
| # We don't use `cargo sqlx prepare --merged` because it rebuilds everything | |
| for i in crates/{a,b,c}; do | |
| (cd "$i" && cargo sqlx prepare -- --lib) | |
| done | |
| # We need to make a merged file at the workspace root for sqlx `offline` | |
| # to work properly with rust-analyzer. Otherwise many red squigglies. | |
| cat crates/*/sqlx-data.json | jq --sort-keys -s add > sqlx-data.json | |
| rm -f crates/*/sqlx-data.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment