Update readme for SQLx.

This commit is contained in:
projectmoon 2020-12-31 14:09:01 +00:00
parent ce4e02594d
commit 2e2cf30755
1 changed files with 29 additions and 12 deletions

View File

@ -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