Clafou/Migration
Migration =========
Installation
Using Xcode, add a package dependency with URL "https://github.com/Clafou/Migration.git"
Usage
Add import Migration then call migrateToVersion with a version number and a block, and Migration will ensure that the block of code is only ever run once for that version.
Migration.migrateToVersion("1.1") {
// Your migration code here
}You would want to run this code in your app delegate or similar.
Because Migration inspects your *-info.plist file for your actual version number and keeps track of the last migration, it will migrate all un-migrated blocks in-between. For example, let's say you had the following migrations:
Migration.migrateToVersion("0.9") {
// Some 0.9 stuff
}
Migration.migrateToVersion("1.0") {
// Some 1.0 stuff
}If a user was at version 0.8, skipped 0.9, and upgraded to 1.0, then both the 0.9 and 1.0 blocks would run.
For debugging/testing purposes, you can call reset to clear out the last recorded migration, causing all migrations to run from the beginning:
Migration.reset()Notes
Migration assumes version numbers are incremented in a logical way, i.e. 1.0.1 -> 1.0.2, 1.1 -> 1.2, etc.
Version numbers that are past the version specified in your app will not be run. For example, if your *-info.plist file specifies 1.2 as the app's version number, and you attempt to migrate to 1.3, the migration will not run.
Blocks are executed on the thread the migration is run on. Background/foreground situations should be considered accordingly.
Contributing
This library does not handle some more intricate migration situations, if you come across intricate use cases from your own app, please add it and submit a pull request. Be sure to add test cases.
Contributors
MTMigration:
Package Metadata
Repository: Clafou/Migration
Stars: 0
Forks: 0
Open issues: 0
Default branch: main
Primary language: swift
License: BSD-2-Clause
README: README.md