integrate migrations

This commit is contained in:
D. Scott Boggs 2023-06-06 12:46:35 -04:00
parent c9c12a0ec7
commit f7e95ea0a8
2 changed files with 13 additions and 1 deletions

View file

@ -4,9 +4,16 @@ mod error;
mod migrator;
use error::Result;
use sea_orm::Database;
use sea_orm_migration::prelude::*;
#[tokio::main]
async fn main() -> Result<()> {
let db = Database::connect(db::connection_url()).await?;
let schema_manager = SchemaManager::new(&db);
migrator::Migrator::refresh(&db).await?;
assert!(schema_manager.has_table("tracks").await?);
assert!(schema_manager.has_table("ticks").await?);
assert!(schema_manager.has_table("groups").await?);
assert!(schema_manager.has_table("track2groups").await?);
Ok(println!("Hello, world! {db:?}"))
}

View file

@ -10,6 +10,11 @@ pub struct Migrator;
#[async_trait::async_trait]
impl MigratorTrait for Migrator {
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
vec![]
vec![
Box::new(m20230606_000001_create_tracks_table::Migration),
Box::new(m20230606_000002_create_ticks_table::Migration),
Box::new(m20230606_000003_create_groups_table::Migration),
Box::new(m20230606_000004_create_track2groups_table::Migration),
]
}
}