run method
Applies any pending migrations and returns the final schema version.
Returns null if the _schema_meta table does not exist — this means
the instance has not been bootstrapped yet and the user needs to run
the setup-screen provisioning flow before incremental updates can run.
Implementation
Future<int?> run() async {
final current = await _readVersion();
if (current == null) return null;
if (current >= schemaExpectedVersion) return current;
final migrations = _overrideMigrations ?? await _migrationLoader();
for (final m in migrations) {
if (m.version > current) {
dev.log('Applying migration ${m.version}…', name: 'SchemaMigrator');
await _client.rpc(
'_apply_migration',
params: {'p_version': m.version, 'p_sql': m.sql},
);
}
}
return schemaExpectedVersion;
}