T-151: M2.1i — findings + provider_caveats append-only PostgreSQL migration (research track, 37-research-findings.sql) with fresh-database schema tests (no adapters, no new deps)

This commit is contained in:
Studio 2026-12-02 00:12:13 -05:00
parent 34fdfd6bc4
commit c16d6b3f60
7 changed files with 672 additions and 11 deletions

View file

@ -78,6 +78,7 @@ const RESEARCH_FILES = [
'32-candidate-parameter-defaults.sql',
'33-candidate-decimal-normalization.sql',
'36-trial-ledger.sql',
'37-research-findings.sql',
];
const cleanup: (() => Promise<void> | void)[] = [];
@ -138,13 +139,13 @@ async function createIsolatedFixture() {
}
describe.skipIf(!url)('fresh PostgreSQL database schema', () => {
test('Case A: init SQL 01-36 contain no CREATE DATABASE/\\c and create all master and research tables', async () => {
test('Case A: init SQL 01-37 contain no CREATE DATABASE/\\c and create all master and research tables', async () => {
const f = await createIsolatedFixture();
const sqlFiles = readdirSync(initDir)
.filter(file => file.endsWith('.sql'))
.sort();
expect(sqlFiles.length).toBeGreaterThanOrEqual(36);
expect(sqlFiles.length).toBeGreaterThanOrEqual(37);
for (const file of sqlFiles) {
const sql = readFileSync(join(initDir, file), 'utf8');
@ -159,7 +160,7 @@ describe.skipIf(!url)('fresh PostgreSQL database schema', () => {
...LEGACY_MASTER_TABLES,
// Security master tables (34)
...SECURITY_MASTER_TABLES,
// Research tables (06-33, 36, including representatives from 12, 16, 20, 22, 28, 30, 36)
// Research tables (06-33, 36-37, including representatives from 12, 16, 20, 22, 28, 30, 36, 37)
'backtests',
'backtest_results',
'runs',
@ -171,6 +172,8 @@ describe.skipIf(!url)('fresh PostgreSQL database schema', () => {
'paper_deployments',
'trial_ledger',
'vault_evaluations',
'findings',
'provider_caveats',
]) {
expect(createdTables.has(expectedTable)).toBe(true);
}
@ -193,6 +196,8 @@ describe.skipIf(!url)('fresh PostgreSQL database schema', () => {
}
expect(createdTables.has('trial_ledger')).toBe(false);
expect(createdTables.has('vault_evaluations')).toBe(false);
expect(createdTables.has('findings')).toBe(false);
expect(createdTables.has('provider_caveats')).toBe(false);
expect(await f.hasColumn('exchanges', 'visible')).toBe(true);
const second = await runPostgresMigrations(f.postgres, { track: 'master' });
@ -200,7 +205,7 @@ describe.skipIf(!url)('fresh PostgreSQL database schema', () => {
expect(await f.recorded()).toEqual(MASTER_FILES);
});
test('Case C: all track with 06-08 pre-applied records master + research (including 36) and never records 06-08', async () => {
test('Case C: all track with 06-08 pre-applied records master + research (including 36-37) and never records 06-08', async () => {
const f = await createIsolatedFixture();
for (const file of BOOTSTRAP_FILES) {
@ -223,6 +228,8 @@ describe.skipIf(!url)('fresh PostgreSQL database schema', () => {
}
expect(createdTables.has('trial_ledger')).toBe(true);
expect(createdTables.has('vault_evaluations')).toBe(true);
expect(createdTables.has('findings')).toBe(true);
expect(createdTables.has('provider_caveats')).toBe(true);
const second = await runPostgresMigrations(f.postgres, { track: 'all' });
expect(second).toEqual([]);