Skip to content

Commit

Permalink
migration table custom name SeaQL/sea-orm#1511
Browse files Browse the repository at this point in the history
  • Loading branch information
darkmmon committed Jul 11, 2023
1 parent ee0b0db commit e11d115
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion SeaORM/docs/0.12.x-CHANGELOG_temp.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ let customer = Customer::find()
assert_eq!(customers.notes, None);
```
* [sea-orm-cli] the `migrate init` command will create a `.gitignore` file when the migration folder reside in a Git repository https://github.com/SeaQL/sea-orm/pull/1334
================================ All Changes above was being Documented ================================
* Added `MigratorTrait::migration_table_name()` method to configure the name of migration table https://github.com/SeaQL/sea-orm/pull/1511
```rs
#[async_trait::async_trait]
Expand All @@ -44,6 +43,7 @@ impl MigratorTrait for Migrator {
}
}
```
================================ All Changes above was being Documented ================================
* Added option to construct chained AND / OR join on condition https://github.com/SeaQL/sea-orm/pull/1433
```rs
use sea_orm::entity::prelude::*;
Expand Down
20 changes: 19 additions & 1 deletion SeaORM/docs/03-migration/01-setting-up-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,25 @@ If you are starting from a fresh database, it's better to version control your d

## Migration Table

A table named `seaql_migrations` will be created in your database to keep track of the applied migrations. It will be created automatically when you run the migration.
A table will be created in your database to keep track of the applied migrations. It will be created automatically when you run the migration.

By default, it will be named `seaql_migrations`. You can also use a custom name for your migration table.
```rust
#[async_trait::async_trait]
impl MigratorTrait for Migrator {
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
vec![
Box::new(m20220118_000001_create_cake_table::Migration),
Box::new(m20220118_000002_create_fruit_table::Migration),
]
}

// Override the name of migration table
fn migration_table_name() -> sea_orm::DynIden {
Alias::new("override_migration_table_name").into_iden()
}
}
```

## Creating Migration Directory

Expand Down

0 comments on commit e11d115

Please sign in to comment.