How can I manually run migrations? #1065
-
I'm using a system where I do an account restore where I overwrite the "app.db" file with another file. I would like to not have to close the app in order for the migrations to be re-run. For example, I may overwrite a file with the schemaVersion of 6 with another with a schemaVersion of 3 and I would like for the migrations to run without the user closing the app. Can I run them on demand? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 19 replies
-
Migrations are run when the schema version of the database file in the device differs from the one that is passed when the db is opened. In the case of moor is through the getter in the AppDatabase file. |
Beta Was this translation helpful? Give feedback.
Migrations are run when the schema version of the database file in the device differs from the one that is passed when the db is opened. In the case of moor is through the getter in the AppDatabase file.
You could create a constructor for the database that receives a specific version. Then you can simply close and reopen the database to trigger the migrations