sea-orm/sea-orm-migration
Billy Chan 94403b5659
migration: schema helper (#2099)
* Adapted loco-rs/schema.rs

* avoid `&mut ColumnDef` after upgraded to sea-query 0.31.0

* refactoring

* rewrite schema.rs

* revert

* fmt

* fix

* loco_example: pin loco-rs version

* refactor
2024-02-06 14:10:36 +08:00
..
2024-02-06 14:10:36 +08:00
2024-01-27 14:36:26 +00:00
2024-02-05 14:42:55 +08:00
2022-05-09 12:30:55 +08:00

SeaORM CLI

Install and Usage:

> cargo install sea-orm-cli 
> sea-orm-cli help

Or:

> cargo install --bin sea
> sea help

Getting Help:

cargo run -- -h

Running Entity Generator:

# 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
    cargo run -- migrate init
    
  • Apply all pending migrations
    cargo run -- migrate
    
    cargo run -- migrate up
    
  • Apply first 10 pending migrations
    cargo run -- migrate up -n 10
    
  • Rollback last applied migrations
    cargo run -- migrate down
    
  • Rollback last 10 applied migrations
    cargo run -- migrate down -n 10
    
  • Drop all tables from the database, then reapply all migrations
    cargo run -- migrate fresh
    
  • Rollback all applied migrations, then reapply all migrations
    cargo run -- migrate refresh
    
  • Rollback all applied migrations
    cargo run -- migrate reset
    
  • Check the status of all migrations
    cargo run -- migrate status