Update readme for SQLx.

This commit is contained in:
jeff 2020-12-31 14:09:01 +00:00
parent 574ab543e5
commit c99c7af369
1 changed files with 29 additions and 12 deletions

View File

@ -7,9 +7,7 @@ Currently under heavy development.
## Build Instructions ## Build Instructions
These are very basic build instructions. They assume you already have These are very basic build instructions. They assume you already have
cargo set up and installed. Building the application requires **Rust cargo set up and installed.
Nightly!** See [rustup documentation][rustup] for more, particularly
the part about using [Rust Nightly][nightly].
### Install Dependencies ### Install Dependencies
@ -23,18 +21,19 @@ Install dependencies. The exact method depends on your OS.
### Initial Setup ### 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 cargo install --version=0.2.0 sqlx-cli
diesel setup cargo run --bin tenebrous-migrate
diesel migration run
``` ```
### Run Application ### Run Application
If you are using `rustup`, then it should automatically switch to the 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. `rust-toolchain` file.
Command line "instructions" to build and run the application: Command line "instructions" to build and run the application:
@ -43,9 +42,27 @@ Command line "instructions" to build and run the application:
cargo run cargo run
``` ```
The sqlite database is currently always created in the same directory The sqlite database is created in the directory `cargo run` was
that `cargo run` was invoked from, so make sure you invoke it from the invoked from by default. You can also pass a path to a different
same place every time. 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 [rustup]: https://rust-lang.github.io/rustup/index.html
[nightly]: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust