onDbDowngrade method

FutureOr<void> onDbDowngrade(
  1. Database db,
  2. int oldVersion,
  3. int newVersion
)
inherited

Implementation

FutureOr<void> onDbDowngrade(
    Database db, int oldVersion, int newVersion) async {
  // Run the CREATE TABLE statement on the database.
  await db.transaction((txn) async {
    var batch = txn.batch();
    List<String> allQueries = [];
    for (var element in tables) {
      final queries = element.downgradeTable(oldVersion, newVersion);
      if (queries.isNotEmpty == true) {
        allQueries.addAll(queries);
        for (var query in queries) {
          batch.execute(query);
        }
      }
    }
    await batch.commit(noResult: true);
    _logBatchResult('onDbDowngrade', allQueries,
        'Database downgraded from $oldVersion to $newVersion');
  });
  await db.transaction((txn) async {
    var batch = txn.batch();
    List<String> allQueries = [];
    for (var element in tables) {
      final queries = element.onDowngradeComplete(oldVersion, newVersion);
      if (queries.isNotEmpty == true) {
        allQueries.addAll(queries);
        for (var query in queries) {
          batch.execute(query);
        }
      }
    }
    await batch.commit(noResult: true);
    _logBatchResult('After onDbDowngrade', allQueries, null);
  });
}