getCurrentVersion method

Future<int> getCurrentVersion(
  1. SqliteWriteContext db
)

Get the last applied migration version in the database.

Implementation

Future<int> getCurrentVersion(SqliteWriteContext db) async {
  try {
    final currentVersionRow = await db.getOptional(
        'SELECT ifnull(max(id), 0) as version FROM $migrationTable');
    int currentVersion =
        currentVersionRow == null ? 0 : currentVersionRow['version'];
    return currentVersion;
  } on SqliteException catch (e) {
    if (e.message.contains('no such table')) {
      return 0;
    }
    rethrow;
  }
}