sea-orm
sea-orm copied to clipboard
MigratorTrait with self
#2803
@ctron can you try this and see if it works for you?
use crate::common::migration::*;
use sea_orm_migration::{MigratorTraitSelf, prelude::*};
pub struct Migrator {
pub i: i32,
}
#[async_trait::async_trait]
impl MigratorTraitSelf for Migrator {
fn migrations(&self) -> Vec<Box<dyn MigrationTrait>> {
vec![
Box::new(m20220118_000001_create_cake_table::Migration),
Box::new(m20220118_000002_create_fruit_table::Migration),
]
}
}
[patch.crates-io]
sea-orm-migration = { git = "https://github.com/SeaQL/sea-orm", branch = "migrator-self" }
I won't be able to actually try it out this week. But taking a quick look, that looks very promising. As the MigrationTrait already uses self, I should be able to pass in arguments to the actual migration. And so that should work!
thanks, please give it a try and let me know. want to have some user feedback before merging this in.