1

I use ObjectBox as a database manager on a Flutter/Dart Application.

I use a pre-filled database (.mdb) which I copy to the application directory at the installation.

  • How to process to a migrate the database?
  • What type of architecture should I set up to perform a migration of both the data present in the database but also the scheme (as we could do with Realm for example)
  • Is it possible to get something like this:
     if (oldVersion == 0) {
       // Migrate DATA or/and Schema from v0 to v1
       oldVersion++;
     }

     if (oldVersion == 1) {
       // Migrate DATA or/and Schema from v1 to v2
       oldVersion++;
     }
Dev Loots
  • 708
  • 9
  • 28

1 Answers1

2

ObjectBox does migrations differently. For many cases, it can do it automatically without any additional information (e.g. adding/removing properties and types). For renames, you have to give some extra information. The whole process is documented here including some background on UIDs (if you are interested, otherwise go to the "how to" section).

From your question, I don't see if that's what you were looking for. In case you want your own logic fired e.g. on an app update, then it's in your hands completely. E.g. you could have your own "meta" type carrying your app version and do any app-dependent updates based on that.

PS.: I'm not sure how the fact that you are dealing with "pre-populated database" should influence this; to my understanding it should not.

Markus Junginger
  • 6,950
  • 31
  • 52