From f7e95ea0a8c65be99742d9ef36fdad0ef808c210 Mon Sep 17 00:00:00 2001 From: "D. Scott Boggs" Date: Tue, 6 Jun 2023 12:46:35 -0400 Subject: [PATCH] integrate migrations --- src/main.rs | 7 +++++++ src/migrator/mod.rs | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 2391e85..79d24ea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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:?}")) } diff --git a/src/migrator/mod.rs b/src/migrator/mod.rs index 242ef4f..473e061 100644 --- a/src/migrator/mod.rs +++ b/src/migrator/mod.rs @@ -10,6 +10,11 @@ pub struct Migrator; #[async_trait::async_trait] impl MigratorTrait for Migrator { fn migrations() -> Vec> { - 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), + ] } }