Skip to content

Migrating from Sqflite #17

Answered by rkistner
aleripe asked this question in Q&A
Oct 7, 2023 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

The migrations in sqlite_async stores more than just the version number, and PRAGMA user_version could have been used for different purposes, so we can't do that check in the core library.

However, you can add a check directly to the app's migrations, such as:

final migrations = SqliteMigrations()
  ..add(SqliteMigration(1, (tx) async {
    final userVersion = (await db.get('PRAMGA user_version'))['user_version'];
    if (userVersion < 1) {
      await tx.execute(
          'CREATE TABLE test_data(id INTEGER PRIMARY KEY AUTOINCREMENT, data TEXT)');
    } else {
       // Already migrated in sqflite, ignore
    }
  }))

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@rkistner
Comment options

Answer selected by aleripe
@aleripe
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants