cargo install diesel_cli --no-default-features --features "postgres" # For PostgreSQL
diesel setup --database-url=postgres://username:password@localhost/database # For PostgreSQL
To apply pending migrations to your database, use the following command:
diesel migration run --database-url=postgres://username:password@localhost/database
To rollback the last applied migration, use the following command:
diesel migration redo --database-url=postgres://username:password@localhost/database
Diesel can generate Rust code for your database schema and models. To generate the code, use:
diesel print-schema --database-url=postgres://username:password@localhost/database > src/schema.rs