mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
SQLiteStore.defaultFileURL access restriction #132
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 @jamesbebbington on GitHub (Apr 12, 2017).
Hey @JohnEstropia,
So the time has come, since having first released our app to create a data migration. Up to now we've been relying on the default config and instantiating our data stack with a simple
CoreStore.addStorageAndWait().However, we now need to allow synchronous lightweight migrations. The README provides this example:
As our app started with CoreStore v1.4.4 I figured I could lean on the
defaultFileURL, like so:However the property is marked
internal. I'd rather not have to duplicate that logic, could this access restriction be relaxed to allow the above? Or is there a better way to do what I'm trying to achieve.Also, is the only difference between
LegacySQLiteStoreandSQLiteStorethe location of the data store file? Should I be updating my app away fromLegacySQLiteStore?Thanks.
@JohnEstropia commented on GitHub (Apr 13, 2017):
LegacySQLiteStoreandSQLiteStoreare just lightweight descriptors. You can simply create an instance to extract the default URL:Yes. The SQLiteStore's default path conforms better to standard iOS and macOS recommended directory naming
Specifically:
If you are supporting migrations, you need to make sure that your future code will result in the exact same URL as your app's old versions. Wether you use
LegacySQLiteStoreorSQLiteStore, I recommend letting your app explicitly provide the file path. You are not "duplicating logic" here, you are ensuring your users can still migrate even if CoreStore changes it's default directories in the future.(Of course I won't make updates like that, but it's safer to be vigilant)
With regards to file paths,
LegacySQLiteStoreandSQLiteStorewill be maintained with considerations to protect past app installs, but future new features will generally be directed towardsSQLiteStore.@jamesbebbington commented on GitHub (Apr 24, 2017):
Thanks @JohnEstropia, that all makes sense.
@jamesbebbington commented on GitHub (Apr 26, 2017):
Hey @JohnEstropia actually, looking back through our project history, we started off with CoreStore v1.4.4 but upgraded to v2.0.6 before our first public release of the app.
So all our users should have their DBs stored at the new
SQLiteStore.defaultFileURLand I can ignore all thisLegacySQLiteStorebusiness right?@JohnEstropia commented on GitHub (Apr 27, 2017):
Since CoreStore 2.0
CoreStore.addStorageAndWait()internally uses SQLiteStore, so yes I think you are all set :)@JohnEstropia commented on GitHub (Apr 27, 2017):
One advise: you can always test migration by installing your app's old version and then running your latest app.