Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deferred migrations system #175

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

recursivetree
Copy link
Contributor

While working on a squad system update, I found a migration that depends on the business logic: https://github.com/eveseat/web/blob/fe45844ab67e68761720ce536d0ce481b4ff0f39/src/database/migrations/2020_12_06_220254_upgrade_squads_maj4_min4_hf2.php

This is a bad idea, since when the data the business logic operates on changes, the migrations breaks since the migration updating the data for the business logic didn't run yet. However, this migration is there to remove a broken state, so not running it is not an option.

The solution that this PR enables are deferred migrations: A migration can schedule a closure that should be run after all other migrations have completed. This means the data is already migrated to a state where the business logic is guaranteed to be able process it.

In a migration, using DeferredMigration::schedule, a migration can schedule a deferred migration:

public function up() {
   DeferredMigration::schedule(function(){
       //runs after all other migrations
   });
}

@Crypta-Eve Crypta-Eve merged commit 09d8b55 into eveseat:5.0.x Feb 14, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants