Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
its: Refactored to extract migrations for command database
- Loading branch information
Showing
8 changed files
with
61 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
mod command_migration_source; | ||
pub mod event_dto; | ||
mod event_store; | ||
mod sqlite_issue_repository; | ||
|
45 changes: 45 additions & 0 deletions
45
its/crates/adapter_sqlite/src/adapter/sqlite/command_migration_source.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use std::{borrow::Cow, future::Future, pin::Pin}; | ||
|
||
use sqlx::{ | ||
error::BoxDynError, | ||
migrate::{Migration, MigrationSource, MigrationType}, | ||
}; | ||
|
||
#[derive(Debug, Default)] | ||
pub struct CommandMigrationSource {} | ||
|
||
impl MigrationSource<'static> for CommandMigrationSource { | ||
fn resolve( | ||
self, | ||
) -> Pin<Box<dyn Future<Output = Result<Vec<Migration>, BoxDynError>> + Send + 'static>> { | ||
Box::pin(async move { | ||
let migrations = vec![ | ||
Migration::new( | ||
20210223000001, | ||
Cow::from("create aggregates"), | ||
MigrationType::Simple, | ||
Cow::from(include_str!( | ||
"../../../sql/command/migrations/20220224000001_create_aggregates.sql" | ||
)), | ||
), | ||
Migration::new( | ||
20210223000002, | ||
Cow::from("create events"), | ||
MigrationType::Simple, | ||
Cow::from(include_str!( | ||
"../../../sql/command/migrations/20220224000002_create_events.sql" | ||
)), | ||
), | ||
Migration::new( | ||
20210223000003, | ||
Cow::from("create issue_ids"), | ||
MigrationType::Simple, | ||
Cow::from(include_str!( | ||
"../../../sql/command/migrations/20220224000003_create_issue_ids.sql" | ||
)), | ||
), | ||
]; | ||
Ok(migrations) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters