Originally created by @dufflink on GitHub (Jan 15, 2019).
Hello! I did as you advised #281 but the problem remained the same.
The initDB function is called every time I log in as a user.
The error occurs only when I log out from the account of one user and immediately try to log in to another user.
Originally created by @dufflink on GitHub (Jan 15, 2019).
Hello! I did as you advised [#281](https://github.com/JohnEstropia/CoreStore/issues/281#issuecomment-444428619) but the problem remained the same.
<img width="1072" alt="2019-01-10 11 46 15" src="https://user-images.githubusercontent.com/29461219/51168294-a871c700-18ca-11e9-8dde-c780c66f09b9.png">
The initDB function is called every time I log in as a user.
The error occurs only when I log out from the account of one user and immediately try to log in to another user.
<img width="462" alt="2019-01-10 11 52 02" src="https://user-images.githubusercontent.com/29461219/51168326-bde6f100-18ca-11e9-9029-6d0e4ae8a183.png">
You are trying to add your sqlite store to a new DataStack when it is still being used by the old DataStack (CoreStore.defaultStack still holds the old stack)
I recommend that you set your CoreStore.defaultStack to a new DataStack, give the old stack time to release itself, then add the sqlite store to the new stack.
@JohnEstropia commented on GitHub (Jan 16, 2019):
You are trying to add your sqlite store to a new DataStack when it is still being used by the old DataStack (CoreStore.defaultStack still holds the old stack)
I recommend that you set your CoreStore.defaultStack to a new DataStack, give the old stack time to release itself, then add the sqlite store to the new stack.
It works for me:
I added a nil check for dataStack
@dufflink commented on GitHub (Jan 17, 2019):
It works for me:
I added a nil check for dataStack
<img width="808" alt="2019-01-17 11 47 32" src="https://user-images.githubusercontent.com/29461219/51300476-d3d0ef00-1a4d-11e9-8ff9-291ec198b494.png">
How can I use two different SQLite stores in one data stack? Now, I still have data from another user (Message, Chats)
@dufflink commented on GitHub (Jan 18, 2019):
How can I use two different SQLite stores in one data stack? Now, I still have data from another user (Message, Chats)
Your issue in #281 is not the database setup code. You have other processes in your app that still use the old DataStack. They may be View Controllers, or something else. That's what you should focus debugging, those objects need to be deallocated before you call initDb() again with the new account.
@JohnEstropia commented on GitHub (Jan 21, 2019):
You will have to release the `DataStack` used by your old account. Your old code was fine: https://github.com/JohnEstropia/CoreStore/issues/281#issuecomment-442388594
Your issue in #281 is not the database setup code. You have other processes in your app that still use the old DataStack. They may be View Controllers, or something else. That's what you should focus debugging, those objects need to be deallocated before you call `initDb()` again with the new account.
I'm closing this issue in a while as this is an application-side issue. I assure you that switching DataStacks work, the CoreStore demo app does it (see: https://github.com/JohnEstropia/CoreStore/blob/40f458a09c0177d15ceab1561acaede2799c4f2d/CoreStoreDemo/CoreStoreDemo/MIgrations%20Demo/MigrationsDemoViewController.swift#L243)
I'd be happy to help you where I can. I do suggest you refer to the MigrationsDemoViewController.swift in the demo app first, it shows a ViewController that changes DataStack and ListMonitor instances each time you tap on a different model version.
@JohnEstropia commented on GitHub (Jan 21, 2019):
@MaxPaymon I don't have a Telegram account, but CoreStore has a Slack group: http://swift-corestore-slack.herokuapp.com/
I'd be happy to help you where I can. I do suggest you refer to the `MigrationsDemoViewController.swift` in the demo app first, it shows a ViewController that changes `DataStack` and `ListMonitor` instances each time you tap on a different model version.
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 @dufflink on GitHub (Jan 15, 2019).
Hello! I did as you advised #281 but the problem remained the same.
The error occurs only when I log out from the account of one user and immediately try to log in to another user.
@JohnEstropia commented on GitHub (Jan 16, 2019):
You are trying to add your sqlite store to a new DataStack when it is still being used by the old DataStack (CoreStore.defaultStack still holds the old stack)
I recommend that you set your CoreStore.defaultStack to a new DataStack, give the old stack time to release itself, then add the sqlite store to the new stack.
@dufflink commented on GitHub (Jan 16, 2019):
How can i give the old stack time to release itself?
@dufflink commented on GitHub (Jan 17, 2019):
It works for me:
I added a nil check for dataStack
@dufflink commented on GitHub (Jan 18, 2019):
How can I use two different SQLite stores in one data stack? Now, I still have data from another user (Message, Chats)
@JohnEstropia commented on GitHub (Jan 21, 2019):
You will have to release the
DataStackused by your old account. Your old code was fine: https://github.com/JohnEstropia/CoreStore/issues/281#issuecomment-442388594Your issue in #281 is not the database setup code. You have other processes in your app that still use the old DataStack. They may be View Controllers, or something else. That's what you should focus debugging, those objects need to be deallocated before you call
initDb()again with the new account.I'm closing this issue in a while as this is an application-side issue. I assure you that switching DataStacks work, the CoreStore demo app does it (see: https://github.com/JohnEstropia/CoreStore/blob/40f458a09c0177d15ceab1561acaede2799c4f2d/CoreStoreDemo/CoreStoreDemo/MIgrations%20Demo/MigrationsDemoViewController.swift#L243)
@dufflink commented on GitHub (Jan 21, 2019):
Could you share your login in Telegram? Or any other social network
@JohnEstropia commented on GitHub (Jan 21, 2019):
@MaxPaymon I don't have a Telegram account, but CoreStore has a Slack group: http://swift-corestore-slack.herokuapp.com/
I'd be happy to help you where I can. I do suggest you refer to the
MigrationsDemoViewController.swiftin the demo app first, it shows a ViewController that changesDataStackandListMonitorinstances each time you tap on a different model version.@dufflink commented on GitHub (Jan 21, 2019):
Ok, thanks!