Frameworks used:
- Rocket - For managing the REST API
- Diesel - ORM that supports psql, mysql etc.
- slog - For logging
Steps to use:
-
First install diesel_cli by using:
cargo install diesel
-
Initialize your new rust project with the template by using:
git clone https://github.com/smoke-trees/rust-backend-template
-
Create a
.env
file in the root directory of your project and set theDATABASE_URL
variable -
Run
diesel setup
to create the database. -
Run
diesel migration run
to create all the necessary tables. Note that the table schemas are written under migrations. -
If you want to create a new migration/table schema, run
diesel migration create YOUR_MIGRATION_NAME
Notes:
- Running migrations manually is only needed during development. The migrations are embedded in the binary and are executed at runtime during production.
Related links:
- Rocket: https://rocket.rs/
- Diesel: http://diesel.rs/