isUpgradePending static method

Future<bool> isUpgradePending(
  1. Database database,
  2. int version
)

Whether opening the existing database runs migrations, as its version is lower than version.

Foreign keys stay disabled while migrating then, as they can't be toggled within the transaction of migrations, e.g. for recreating tables.

Implementation

static Future<bool> isUpgradePending(
  final Database database,
  final int version,
) async {
  final currentVersion = await database.getVersion();
  return currentVersion != 0 && currentVersion < version;
}