runMigrations function
Runs pending migrations in order. Called internally by PlexDb.initialize.
Implementation
Future<void> runMigrations(PlexDb db, List<PlexDbMigration> migrations) async {
if (migrations.isEmpty) return;
var currentVersion = 0;
final stored = await db.getFromCache('_plex_schema_version');
if (stored != null && stored['v'] != null) {
currentVersion = (stored['v'] as num).toInt();
}
final sorted = List<PlexDbMigration>.from(migrations)
..sort((a, b) => a.version.compareTo(b.version));
for (final m in sorted) {
if (m.version <= currentVersion) continue;
await m.up(db);
currentVersion = m.version;
await db.putInCache('_plex_schema_version', {'v': currentVersion});
}
}