mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 05:21:15 +00:00
fix(server): the newer-database refusal also names a development build as the cause
A database a feature-branch build migrated carries migrations this build does not ship too, and was told it came from a newer TREK.
This commit is contained in:
@@ -251,7 +251,8 @@ export async function migrateToHead(
|
||||
|
||||
/**
|
||||
* A database a newer TREK migrated carries migrations this build does not
|
||||
* ship. An image rolled back, or a newer backup restored, would otherwise run
|
||||
* ship; so does one a feature-branch build migrated, which is why the message
|
||||
* names both. An image rolled back, or a newer backup restored, would otherwise run
|
||||
* older code against a schema it does not know and fail later, far from the
|
||||
* cause. Refused before anything is written.
|
||||
*/
|
||||
@@ -259,7 +260,8 @@ export function refuseNewerDatabase(executed: string[], known: Set<string>, rest
|
||||
const unknown = unknownMigrations(executed, known);
|
||||
if (unknown.length === 0) return;
|
||||
throw new Error(
|
||||
`${REFUSAL} the database was migrated by a newer TREK (${unknown.length} unknown migration(s), latest ${unknown[unknown.length - 1]}). ` +
|
||||
`${REFUSAL} the database was migrated by a newer TREK (${unknown.length} unknown migration(s), latest ${unknown[unknown.length - 1]}), ` +
|
||||
'or by a development build that added migrations of its own. ' +
|
||||
'Run that version again, or restore a backup taken with this one.' +
|
||||
(restoreHint ? ` ${restoreHint}` : ''),
|
||||
);
|
||||
|
||||
@@ -36,5 +36,6 @@ describe('known migrations', () => {
|
||||
expect(unknownMigrations(['Migration1_a', 'Migration3_c'], known)).toEqual(['Migration3_c']);
|
||||
expect(() => refuseNewerDatabase(['Migration1_a', 'Migration2_b'], known)).not.toThrow();
|
||||
expect(() => refuseNewerDatabase(['Migration1_a', 'Migration3_c'], known)).toThrow(/newer TREK/);
|
||||
expect(() => refuseNewerDatabase(['Migration1_a', 'Migration3_c'], known)).toThrow(/or by a development build/);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user