kellnr-migration 6.0.1

Kellnr is a self-hosted registry for Rust crates with support for rustdocs and crates.io caching.
Documentation

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
    

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).