Skip to content

Commit

Permalink
Running migration on any Postgres schema (SeaQL/sea-orm#1056)
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1624 committed Oct 31, 2022
1 parent 673975f commit 22f4fae
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions SeaORM/docs/03-migration/03-running-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,23 @@ Migrator::refresh(db).await?;
/// Rollback all applied migrations
Migrator::reset(db).await?;
```

## Running Migration on Any PostgreSQL Schema

By default migration will be run on the `public` schema, you can now override it when running migration on the CLI or programmatically.

For CLI, you can specify the target schema with `-s` / `--database_schema` option:
* via sea-orm-cli: `sea-orm-cli migrate -u postgres://root:root@localhost/database -s my_schema`
* via SeaORM migrator: `cargo run -- -u postgres://root:root@localhost/database -s my_schema`

You can also run the migration on the target schema programmatically:

```rust
let connect_options = ConnectOptions::new("postgres://root:root@localhost/database".into())
.set_schema_search_path("my_schema".into()) // Override the default schema
.to_owned();

let db = Database::connect(connect_options).await?

migration::Migrator::up(&db, None).await?;
```

0 comments on commit 22f4fae

Please sign in to comment.