60cbe8a75e
Staging web never became healthy because /api/health selected migration.schema_migrations as app_runtime, which is forbidden, so Docker rolled the image back. Co-authored-by: Cursor <cursoragent@cursor.com>
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
/**
|
|
* Health contract for rectification schema. gitCommit proves the web image;
|
|
* latestMigration proves the business database actually applied the SQL.
|
|
*/
|
|
export const RECTIFICATION_CONTRACT_VERSION = "v4";
|
|
|
|
export const REQUIRED_RECTIFICATION_MIGRATIONS = [
|
|
"20260826010000_rectification_inference_round_audit.sql",
|
|
"20260826020000_rectification_choice_focus_identity.sql",
|
|
"20260826030000_rectification_migration_ledger_health.sql",
|
|
] as const;
|
|
|
|
export type DatabaseHealth = Readonly<{
|
|
latestMigration: string | null;
|
|
rectificationContractVersion: typeof RECTIFICATION_CONTRACT_VERSION;
|
|
requiredMigrationsPresent: boolean;
|
|
missingMigrations: readonly string[];
|
|
}>;
|
|
|
|
export function databaseHealthFromFilenames(
|
|
filenames: readonly string[],
|
|
): DatabaseHealth {
|
|
const present = new Set(filenames);
|
|
const missing = REQUIRED_RECTIFICATION_MIGRATIONS.filter((name) => !present.has(name));
|
|
const latest = [...filenames].sort().at(-1) ?? null;
|
|
return {
|
|
latestMigration: latest,
|
|
rectificationContractVersion: RECTIFICATION_CONTRACT_VERSION,
|
|
requiredMigrationsPresent: missing.length === 0,
|
|
missingMigrations: missing,
|
|
};
|
|
}
|