# Running Migrator CLI
- Generate a new migration file
```sh
cargo run -- generate MIGRATION_NAME
```
- Apply all pending migrations
```sh
cargo run
```
```sh
cargo run -- up
```
- Apply first 10 pending migrations
```sh
cargo run -- up -n 10
```
- Rollback last applied migrations
```sh
cargo run -- down
```
- Rollback last 10 applied migrations
```sh
cargo run -- down -n 10
```
- Drop all tables from the database, then reapply all migrations
```sh
cargo run -- fresh
```
- Rollback all applied migrations, then reapply all migrations
```sh
cargo run -- refresh
```
- Rollback all applied migrations
```sh
cargo run -- reset
```
- Check the status of all migrations
```sh
cargo run -- status
```
# Changing database scheme
1. Change `src/iden.rs`.
2. Create new migration under `src/m20220101_00000XX_create_table.rs`.
3. Add the migration in `src/lib.rs`.
4. Apply migration (on postgres, sqlite will give wrong types in the
autogenerated entities, application by `cargo run` in `migration` directory
may fail, while running the whole `kellnr` succeeds).
5. Generate new entities running `sea-orm-cli generate entity -u
postgresql://admin:admin@127.0.0.1/kellnr_dbpostgresql://admin:admin@127.0.0.1/kellnr_db` (adjust this command
appropriately) in the `src/m20220101_00000XX_create_table_entities`
directory.
6. Copy entities to `../entity/src` (`mod.rs` shall go to `lib.rs`).