querySchemaVersion method

  1. @override
Future<String?> querySchemaVersion()
inherited

Implementation

@override
Future<String?> querySchemaVersion() async {
  if (!(await migrationsTableExists())) {
    return null;
  }

  // The hard-coded version '0' below corresponds to the version of the internal migration defined in `schema.ts`.
  // We're ignoring it because this function is supposed to return the application schema version.
  final schemaVersion = '''
    SELECT version FROM $migrationsTable
      WHERE version != '0'
      ORDER BY version DESC
      LIMIT 1
  ''';
  final rows = await adapter.query(Statement(schemaVersion));
  if (rows.isEmpty) {
    return null;
  }

  return rows.first['version']! as String;
}