FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

glados/migration at master · optimism-java/glados · GitHub

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Migration commands

Using sea-orm-cli

Install

cargo install sea-orm-cli

Create (if none already created) a new blank postgres instance: docker run --name postgres -e POSTGRES_DB=glados POSTGRES_PASSWORD=password -d -p 5432:5432 postgres export DATABASE_URL=postgres://postgres:password@localhost:5432/glados

Generate all entities. Commands are made from the project root directory.
```command
sea-orm-cli generate entity -o entity/src

Generate entity only for MyNewTable as defined in a migration (./migration/src/*.rs) file:

sea-orm-cli generate entity -o entity/src -t my_new_table

Make the tables/changes in the new database:

sea-orm-cli migrate up

Running Migrator CLI

  • Generate a new migration file
    cargo run -- generate MIGRATION_NAME
  • Apply all pending migrations
    cargo run
    cargo run -- up
  • Apply first 10 pending migrations
    cargo run -- up -n 10
  • Rollback last applied migrations
    cargo run -- down
  • Rollback last 10 applied migrations
    cargo run -- down -n 10
  • Drop all tables from the database, then reapply all migrations
    cargo run -- fresh
  • Rollback all applied migrations, then reapply all migrations
    cargo run -- refresh
  • Rollback all applied migrations
    cargo run -- reset
  • Check the status of all migrations
    cargo run -- status

Back | FazBrowse Home | New Git URL