mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-12 04:10:36 +01:00
Question about migration #325
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @virulentum on GitHub (Apr 17, 2020).
Is there any way to perform two migrations at once: first a lightweight one and second a heavyweight one?
For example, I have only three models in an app: "Model V1", "Model V20", "Model V21".
Current version of database may be different (V10, V11, ..., V20)
I would like to make migration from current to V20 (lightweight) and after that make migration from V20 to V21 (heavyweight).
I can do that in two step by adding two storages, but I would like to do it at once
Could you help me to solve this problem?
@JohnEstropia commented on GitHub (Apr 18, 2020):
Not with the built-in methods. Tracking the versioning for such cases means your app needs to manage the version data somewhere else, so you will have to write one yourself.
@virulentum commented on GitHub (Apr 18, 2020):
So, it means that I cannot do something like:
let sqlStore = SQLiteStore(fileURL: url, migrationMappingProviders: [ mappingProvider1, mappingProvider2 ])where
mappingProvider1for lightweight migration andmappingProvider2for heavyweight migration.Is it true?
@JohnEstropia commented on GitHub (Apr 18, 2020):
@virulentum Sorry, I think I misunderstood what you were trying to do.
If you are just trying to mix light and heavy migrations as part of the
MigrationChainsteps, then yes, themigrationMappingProviderswill let you do that.@virulentum commented on GitHub (Apr 18, 2020):
@JohnEstropia, well, it sounds good, but I have trouble with creating lightweight mapping provider, because I have only models V1, V20 and V21. How can I inform CoreStore, that a mapping provider is for a lightweight migration?
@JohnEstropia commented on GitHub (Apr 18, 2020):
@virulentum As long as the
migrationChainparameter of theDataStackinitializer contains the mapping for each step in the progressive migration, anything not explicitly included in the storagemigrationMappingProviderswill automatically attempt to use lightweight migration.@JohnEstropia commented on GitHub (Apr 18, 2020):
See: https://github.com/JohnEstropia/CoreStore#custom-migrations
@virulentum commented on GitHub (Apr 19, 2020):
@JohnEstropia thank you very much for your answer!