mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 01:28:55 +00:00
fix(db): append the incoming leg mode migration so upgrades pick it up
This commit is contained in:
@@ -32,6 +32,27 @@ describe('incoming_leg_transport_mode migration', () => {
|
||||
const cols = testDb.prepare(`PRAGMA table_info(day_assignments)`).all() as { name: string }[];
|
||||
expect(cols.map(c => c.name)).toContain('incoming_leg_transport_mode');
|
||||
});
|
||||
|
||||
// The case above starts from an empty database and runs every migration, so it
|
||||
// passes wherever this one sits in the array. Existing installs replay only the
|
||||
// slots above their schema_version, which is why the migration has to be the
|
||||
// trailing entry: from anywhere but the end it is silently skipped on upgrade.
|
||||
it('still lands on a database that already holds every earlier migration', () => {
|
||||
const upgraded = new Database(':memory:');
|
||||
upgraded.exec('PRAGMA foreign_keys = ON');
|
||||
createTables(upgraded);
|
||||
runMigrations(upgraded);
|
||||
|
||||
const { version } = upgraded.prepare('SELECT version FROM schema_version').get() as { version: number };
|
||||
upgraded.exec('ALTER TABLE day_assignments DROP COLUMN incoming_leg_transport_mode');
|
||||
upgraded.prepare('UPDATE schema_version SET version = ?').run(version - 1);
|
||||
|
||||
runMigrations(upgraded);
|
||||
|
||||
const cols = upgraded.prepare(`PRAGMA table_info(day_assignments)`).all() as { name: string }[];
|
||||
expect(cols.map(c => c.name)).toContain('incoming_leg_transport_mode');
|
||||
upgraded.close();
|
||||
});
|
||||
});
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user