-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically set SQLX_OFFLINE when crates are used as dependencies
Users of these libraries may not have a database with the right schema. We don't want to require that so we need to make sure to use the saved .sqlx queries when building as a package. The way this is done is by setting SQLX_OFFLINE=true and SQLX_OFFLINE_DIR=.sqlx in the build.rs scripts of the relevant packages. This means that the DATABASE_URL environment variable will be ignored and that `cargo sqlx prepare` will not prepare queries for these libraries. To make it work locally, if DURABLE_DEVELOPMENT=1 then we don't do any overrides. We then set DURABLE_DEVELOPMENT=1 in .cargo/config.toml.
- Loading branch information
Showing
3 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
fn main() { | ||
let development = std::env::var_os("DURABLE_DEVELOPMENT") | ||
.map(|var| var == "1" || var == "true") | ||
.unwrap_or(false); | ||
|
||
if !development { | ||
println!("cargo::rustc-env=SQLX_OFFLINE=true"); | ||
println!("cargo::rustc-env=SQLX_OFFLINE_DIR=.sqlx"); | ||
} | ||
} |
This file contains 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