Skip to content

Commit

Permalink
apply app migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Jan 26, 2025
1 parent 760276d commit b4be5a5
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions fastn-core/src/migrations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,27 @@ pub(crate) async fn migrate(config: &fastn_core::Config) -> Result<(), Migration
}

async fn migrate_app(config: &fastn_core::Config, now: i64) -> Result<(), MigrationError> {
migrate_(
config,
config.package.migrations.as_slice(),
config.package.name.as_str(),
now,
)
.await
if !config.package.migrations.is_empty() {
migrate_(
config,
config.package.migrations.as_slice(),
config.package.name.as_str(),
now,
)
.await?;
}

for app in config.package.apps.iter() {
migrate_(
config,
app.package.migrations.as_slice(),
app.name.as_str(),
now,
)
.await?;
}

Ok(())
}

async fn migrate_fastn(config: &fastn_core::Config, now: i64) -> Result<(), MigrationError> {
Expand Down Expand Up @@ -110,6 +124,11 @@ fn validate_migration(

fn has_migrations(config: &fastn_core::Config) -> bool {
!config.package.migrations.is_empty()
|| config
.package
.apps
.iter()
.any(|a| !a.package.migrations.is_empty())
}

async fn create_migration_table(config: &fastn_core::Config) -> Result<(), fastn_utils::SqlError> {
Expand Down

0 comments on commit b4be5a5

Please sign in to comment.