(db: SqliteDatabase, fromVersion: number)
| 130 | * Run all pending migrations |
| 131 | */ |
| 132 | export function runMigrations(db: SqliteDatabase, fromVersion: number): void { |
| 133 | const pending = migrations.filter((m) => m.version > fromVersion); |
| 134 | |
| 135 | if (pending.length === 0) { |
| 136 | return; |
| 137 | } |
| 138 | |
| 139 | // Sort by version |
| 140 | pending.sort((a, b) => a.version - b.version); |
| 141 | |
| 142 | // Run each migration in a transaction |
| 143 | for (const migration of pending) { |
| 144 | db.transaction(() => { |
| 145 | migration.up(db); |
| 146 | recordMigration(db, migration.version, migration.description); |
| 147 | })(); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * Check if the database needs migration |
no test coverage detected