Merged
Conversation
9c42b18 to
9a811e1
Compare
9a811e1 to
4ec82f0
Compare
Owner
Author
|
@bok- I'm about to merge this pull request, because I think it covers all use cases I could foresee. Apps will have all the information they need in order to implement the logic relevant to their use case. Your own use case is slightly specific because:
Maybe you'll write something like: struct NeedsEraseDatabaseError: Error { }
migrator.registerMigration("v3", merging: ["v1", "v2"]) { db, appliedIDs in
if appliedIDs.isEmpty == false {
// The merged migrations were v1 and/or v2 are already applied.
// We do not support this scenario because we can only
// apply the v3 schema in its entirety: so let's just reset
// the database.
throw NeedsEraseDatabaseError()
}
// Apply full schema v3
}
...
do {
try migrator.migrate(writer)
} catch is NeedsEraseDatabaseError {
try writer.erase()
try migrator.migrate(writer)
} |
4ec82f0 to
85ad232
Compare
Owner
Author
|
⛵ Shipped in v7.8.0 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The new
registerMigration(_:foreignKeyChecks:merging:migrate)method registers a migration that merges and replaces a set of migrations defined in a previous version of the application. For example, to merge the migrations "v1", "v2" and "v3", redefine the "v3" migration so that it merges "v1" and "v2", as in the example below.The second argument of the migration closure is the set of merged migrations that has been applied when the merged migration runs.
See #1817 for a longer discussion.