#orm #async #mysql #postgresql

sea-orm-migration

Migration utility for SeaORM

109 releases (23 stable)

Uses new Rust 2024

2.0.0-rc.40 May 30, 2026
2.0.0-rc.37 Mar 9, 2026
2.0.0-rc.27 Dec 30, 2025
2.0.0-rc.19 Nov 23, 2025
0.9.1 Jul 21, 2022

#198 in #mysql

Download history 16938/week @ 2026-03-03 124701/week @ 2026-03-10 100152/week @ 2026-03-17 112868/week @ 2026-03-24 107227/week @ 2026-03-31 147588/week @ 2026-04-07 139407/week @ 2026-04-14 124227/week @ 2026-04-21 152920/week @ 2026-04-28 162670/week @ 2026-05-05 137795/week @ 2026-05-12 174472/week @ 2026-05-19 151722/week @ 2026-05-26 167665/week @ 2026-06-02

657,270 downloads per month
Used in 283 crates (150 directly)

MIT/Apache

86KB
2K SLoC

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
    

Dependencies

~12–25MB
~396K SLoC