* Refactor `ConnectionTrait` * Refactoring * Build index & foreign key statements * Fix imports * Fixup * Rocket example with migration * async-std compatible with the tokio 1.0 runtime * Use reexported dependency * Compile without selecting any db backend * Updating sea-orm-cli dep * sea-orm-cli migrate commands * cargo fmt * Test [cli] * Refactoring * Clap app name should be "sea-orm-cli" * Correctly capture MIGRATION_DIR * Rename README * Add `sea-orm-cli migrate init` command * Update README * Try restructured sea-query dependency (SeaQL/sea-schema#41) * Set `DATABASE_URL` environment variable
64 lines
1.3 KiB
Markdown
64 lines
1.3 KiB
Markdown
# SeaORM CLI
|
|
|
|
Getting Help:
|
|
|
|
```sh
|
|
cargo run -- -h
|
|
```
|
|
|
|
## Running Entity Generator:
|
|
|
|
```sh
|
|
# MySQL (`--database-schema` option is ignored)
|
|
cargo run -- generate entity -u mysql://sea:sea@localhost/bakery -o out
|
|
|
|
# SQLite (`--database-schema` option is ignored)
|
|
cargo run -- generate entity -u sqlite://bakery.db -o out
|
|
|
|
# PostgreSQL
|
|
cargo run -- generate entity -u postgres://sea:sea@localhost/bakery -s public -o out
|
|
```
|
|
|
|
## Running Migration:
|
|
|
|
- Initialize migration directory
|
|
```sh
|
|
cargo run -- migrate init
|
|
```
|
|
- Apply all pending migrations
|
|
```sh
|
|
cargo run -- migrate
|
|
```
|
|
```sh
|
|
cargo run -- migrate up
|
|
```
|
|
- Apply first 10 pending migrations
|
|
```sh
|
|
cargo run -- migrate up -n 10
|
|
```
|
|
- Rollback last applied migrations
|
|
```sh
|
|
cargo run -- migrate down
|
|
```
|
|
- Rollback last 10 applied migrations
|
|
```sh
|
|
cargo run -- migrate down -n 10
|
|
```
|
|
- Drop all tables from the database, then reapply all migrations
|
|
```sh
|
|
cargo run -- migrate fresh
|
|
```
|
|
- Rollback all applied migrations, then reapply all migrations
|
|
```sh
|
|
cargo run -- migrate refresh
|
|
```
|
|
- Rollback all applied migrations
|
|
```sh
|
|
cargo run -- migrate reset
|
|
```
|
|
- Check the status of all migrations
|
|
```sh
|
|
cargo run -- migrate status
|
|
```
|
|
|