From c99c7af369135dff689dcfaaee510782d5d0dcb4 Mon Sep 17 00:00:00 2001 From: jeff Date: Thu, 31 Dec 2020 14:09:01 +0000 Subject: [PATCH] Update readme for SQLx. --- README.md | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index db58fee..de6d85d 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,7 @@ Currently under heavy development. ## Build Instructions These are very basic build instructions. They assume you already have -cargo set up and installed. Building the application requires **Rust -Nightly!** See [rustup documentation][rustup] for more, particularly -the part about using [Rust Nightly][nightly]. +cargo set up and installed. ### Install Dependencies @@ -23,18 +21,19 @@ Install dependencies. The exact method depends on your OS. ### Initial Setup -Follow these instructions from the root of the repository. Set up database: +Follow these instructions from the root of the repository. + +Set up database: ``` -cargo install diesel_cli --no-default-features --features sqlite -diesel setup -diesel migration run +cargo install --version=0.2.0 sqlx-cli +cargo run --bin tenebrous-migrate ``` ### Run Application If you are using `rustup`, then it should automatically switch to the -nightly version of Rust in this repository. This is because of the +stable version of Rust in this repository. This is because of the `rust-toolchain` file. Command line "instructions" to build and run the application: @@ -43,9 +42,27 @@ Command line "instructions" to build and run the application: cargo run ``` -The sqlite database is currently always created in the same directory -that `cargo run` was invoked from, so make sure you invoke it from the -same place every time. +The sqlite database is created in the directory `cargo run` was +invoked from by default. You can also pass a path to a different +location as a single argument to the program. + +## Development + +Development instructions. + +To set up a local database, or run migrations, run: + +``` +cargo run --bin tenebrous-migrate +``` + +### Database Queries and Migrations + +When adding/updating a compile-checked query or a migration, you need +to update the SQLx data JSON file: + +``` +cargo sqlx prepare -- --bin tenebrous +``` [rustup]: https://rust-lang.github.io/rustup/index.html -[nightly]: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust