Originally created by @sidlatau on GitHub (Sep 28, 2015).
I was unable to enable automatic migrations without modifying CoreStore code (to enable NSMigratePersistentStoresAutomaticallyOption and NSInferMappingModelAutomaticallyOption flags).
I added additional parameter to addSQLiteStoreAndWait method for passing options.
try dataStack.addSQLiteStoreAndWait(
fileURL: sqliteFileURL, // set the target file URL for the sqlite file
storeOptions: [NSSQLitePragmasOption: ["journal_mode": "WAL"], NSMigratePersistentStoresAutomaticallyOption: true, NSInferMappingModelAutomaticallyOption: true]
)
Is there a better way to enable automatic migrations without this modification?
Originally created by @sidlatau on GitHub (Sep 28, 2015).
I was unable to enable automatic migrations without modifying CoreStore code (to enable NSMigratePersistentStoresAutomaticallyOption and NSInferMappingModelAutomaticallyOption flags).
I added additional parameter to addSQLiteStoreAndWait method for passing options.
```
try dataStack.addSQLiteStoreAndWait(
fileURL: sqliteFileURL, // set the target file URL for the sqlite file
storeOptions: [NSSQLitePragmasOption: ["journal_mode": "WAL"], NSMigratePersistentStoresAutomaticallyOption: true, NSInferMappingModelAutomaticallyOption: true]
)
```
Is there a better way to enable automatic migrations without this modification?
adam
added the question label 2025-12-29 18:21:22 +01:00
@sidlatau Thanks for the feedback!
The DataStack already sets ["journal_mode": "WAL"] for you! If you search the code for "journal_mode": "WAL" you'll see that it's being set inside addSQLiteStoreAndWait(...).
As for NSMigratePersistentStoresAutomaticallyOption, and NSInferMappingModelAutomaticallyOption, CoreStore is smart enough to do the same migration introspection without setting these flags. But, CoreStore does not allow migrations when you use addSQLiteStoreAndWait(...) because this is a blocking method and migrations may take time. To support migrations, you have to use the asynchronous methods of the form addSQLiteStore(... completion:) instead.
It will help you a lot if you read the README on migrations for more details. Feel free to ask any other questions!
@JohnEstropia commented on GitHub (Sep 28, 2015):
@sidlatau Thanks for the feedback!
The `DataStack` already sets `["journal_mode": "WAL"]` for you! If you search the code for **"journal_mode": "WAL"** you'll see that it's being set inside `addSQLiteStoreAndWait(...)`.
As for `NSMigratePersistentStoresAutomaticallyOption`, and `NSInferMappingModelAutomaticallyOption`, CoreStore is smart enough to do the same migration introspection without setting these flags. But, CoreStore does not allow migrations when you use `addSQLiteStoreAndWait(...)` because this is a blocking method and migrations may take time. To support migrations, you have to use the asynchronous methods of the form `addSQLiteStore(... completion:)` instead.
It will help you a lot if you read the README on [migrations](https://github.com/JohnEstropia/CoreStore#migrations) for more details. Feel free to ask any other questions!
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @sidlatau on GitHub (Sep 28, 2015).
I was unable to enable automatic migrations without modifying CoreStore code (to enable NSMigratePersistentStoresAutomaticallyOption and NSInferMappingModelAutomaticallyOption flags).
I added additional parameter to addSQLiteStoreAndWait method for passing options.
Is there a better way to enable automatic migrations without this modification?
@JohnEstropia commented on GitHub (Sep 28, 2015):
@sidlatau Thanks for the feedback!
The
DataStackalready sets["journal_mode": "WAL"]for you! If you search the code for "journal_mode": "WAL" you'll see that it's being set insideaddSQLiteStoreAndWait(...).As for
NSMigratePersistentStoresAutomaticallyOption, andNSInferMappingModelAutomaticallyOption, CoreStore is smart enough to do the same migration introspection without setting these flags. But, CoreStore does not allow migrations when you useaddSQLiteStoreAndWait(...)because this is a blocking method and migrations may take time. To support migrations, you have to use the asynchronous methods of the formaddSQLiteStore(... completion:)instead.It will help you a lot if you read the README on migrations for more details. Feel free to ask any other questions!