Originally created by @alinpetrus on GitHub (Mar 8, 2022).
We are using CoreStore and while we love it, there is one thing that is causing us a bit of trouble. When wanting to clear the whole database, we need to go through all the entities and do calls to deleteAll for each entity.
For large datasets this is fairly time consuming.
I am wondering if we could have something which is faster like using NSBatchDeleteRequest or a call to destroyPersistentStore on each store and recreating them afterwards.
Originally created by @alinpetrus on GitHub (Mar 8, 2022).
We are using CoreStore and while we love it, there is one thing that is causing us a bit of trouble. When wanting to clear the whole database, we need to go through all the entities and do calls to deleteAll for each entity.
For large datasets this is fairly time consuming.
I am wondering if we could have something which is faster like using NSBatchDeleteRequest or a call to destroyPersistentStore on each store and recreating them afterwards.
@alinpetrus Thanks. Should be simple enough to expose a safe method for it (since cs_eraseStorageAndWait() already exists for the purpose of migrations). The hard part is ensuring that the existing observers are notified of the deletions. I'll try to push a prototype into develop this weekend and let you play with it before we merge it to main.
In the mean time, if you can ensure that all references to the DataStack can be initialized, you can just replace your DataStack with a new one, delete the files related to the old SQLiteStore().fileURL, and re-add the SQLiteStore to the new DataStack. I have two projects that does this safely, but yeah we should have a supported safe way to remove stores in the API.
@JohnEstropia commented on GitHub (Mar 9, 2022):
@alinpetrus Thanks. Should be simple enough to expose a safe method for it (since `cs_eraseStorageAndWait()` already exists for the purpose of migrations). The hard part is ensuring that the existing observers are notified of the deletions. I'll try to push a prototype into `develop` this weekend and let you play with it before we merge it to `main`.
In the mean time, if you can ensure that all references to the `DataStack` can be initialized, you can just replace your `DataStack` with a new one, delete the files related to the old `SQLiteStore().fileURL`, and re-add the `SQLiteStore` to the new `DataStack`. I have two projects that does this safely, but yeah we should have a supported safe way to remove stores in the API.
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 @alinpetrus on GitHub (Mar 8, 2022).
We are using CoreStore and while we love it, there is one thing that is causing us a bit of trouble. When wanting to clear the whole database, we need to go through all the entities and do calls to deleteAll for each entity.
For large datasets this is fairly time consuming.
I am wondering if we could have something which is faster like using NSBatchDeleteRequest or a call to destroyPersistentStore on each store and recreating them afterwards.
@JohnEstropia commented on GitHub (Mar 9, 2022):
@alinpetrus Thanks. Should be simple enough to expose a safe method for it (since
cs_eraseStorageAndWait()already exists for the purpose of migrations). The hard part is ensuring that the existing observers are notified of the deletions. I'll try to push a prototype intodevelopthis weekend and let you play with it before we merge it tomain.In the mean time, if you can ensure that all references to the
DataStackcan be initialized, you can just replace yourDataStackwith a new one, delete the files related to the oldSQLiteStore().fileURL, and re-add theSQLiteStoreto the newDataStack. I have two projects that does this safely, but yeah we should have a supported safe way to remove stores in the API.