Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to load a database dynamically by name *without* resetting/deleting existing one? #1449

Closed
c0state opened this issue Sep 22, 2017 · 3 comments

Comments

@c0state
Copy link

c0state commented Sep 22, 2017

DBFlow Version: 4.1.1
Issue Kind: Question (and possiblyFeature):

Description:
Starting in DBFlow version 4.1.0, there is the ability to dynamically load another database file via a FlowManager.getDatabase(MyDatabase.class).reset(...) call. However, this method deletes the existing database. Is there a way (or something planned) to load another database but leave the existing one intact?

The use case I have is an app with a catalog of "products" that the user can select. Each product has a database associated with it where the model is the same across products. Upon selection of a particular product, I'd like to dynamically load said product. Only one product is active at a time.

@baranowskinet
Copy link

baranowskinet commented Sep 26, 2017

DBFlow Version: 4.1.1
Issue Kind: Bug & Question

Maybe this should be raised as other issue but this is related to above question.
With new way of init database (no more annotation for name) there is a problem when user want to open another database. I have two databases and I separately opening them as I am also using SqlCipher and to open second db I need to know password. When I call second time FlowManager.init(..) system already has cached all my db definitions and it is using cached empty definition. Result of it is that second db has default CalssName.db file name instead of what I want to pass in second init. Solution for it is add all possible config in first init but still I need to call init to pass specific password via openHelper.

I would like to have possibility of manage each db individually based on database name not by class. Ability to close db without delete database, open new/existing database which are based on the same class but has different names. Purpose: multi-database system when each user has own db encrypted with own password but used the same class including the same migrations scripts.

@carmas123
Copy link

+1

@agrosner
Copy link
Owner

in develop for 4.1.1. call database<MyDatabase>().reopen(newConfig) if you're Kotlin consumer. otherwise use FlowManager.getDatabase(...).reopen(newConfig)

@agrosner agrosner mentioned this issue Oct 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants