T-36: M1.1a — Security master DDL migration (11 tables on the master track)
This commit is contained in:
parent
3e1f108c6f
commit
8326d24957
6 changed files with 914 additions and 27 deletions
|
|
@ -19,6 +19,29 @@ const MASTER_FILES = [
|
|||
'03-initial-data.sql',
|
||||
'04-provider-exchange-mapping-schema.sql',
|
||||
'05-add-visible-column.sql',
|
||||
'34-security-master.sql',
|
||||
];
|
||||
|
||||
const LEGACY_MASTER_TABLES = [
|
||||
'exchanges',
|
||||
'symbols',
|
||||
'provider_exchange_mappings',
|
||||
'provider_mappings',
|
||||
'sync_status',
|
||||
];
|
||||
|
||||
const SECURITY_MASTER_TABLES = [
|
||||
'exchange',
|
||||
'exchange_source_map',
|
||||
'instrument',
|
||||
'instrument_identifier_history',
|
||||
'listing',
|
||||
'corporate_action_continuity',
|
||||
'listing_symbol_history',
|
||||
'provider_mapping',
|
||||
'resolution_conflict',
|
||||
'override',
|
||||
'golden_field_audit',
|
||||
];
|
||||
|
||||
const BOOTSTRAP_FILES = [
|
||||
|
|
@ -113,13 +136,13 @@ async function createIsolatedFixture() {
|
|||
}
|
||||
|
||||
describe.skipIf(!url)('fresh PostgreSQL database schema', () => {
|
||||
test('Case A: init SQL 01-33 contain no CREATE DATABASE/\\c and create all master and research tables', async () => {
|
||||
test('Case A: init SQL 01-34 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(33);
|
||||
expect(sqlFiles.length).toBeGreaterThanOrEqual(34);
|
||||
|
||||
for (const file of sqlFiles) {
|
||||
const sql = readFileSync(join(initDir, file), 'utf8');
|
||||
|
|
@ -130,12 +153,10 @@ describe.skipIf(!url)('fresh PostgreSQL database schema', () => {
|
|||
|
||||
const createdTables = new Set(await f.tables());
|
||||
for (const expectedTable of [
|
||||
// Master tables (02-05)
|
||||
'exchanges',
|
||||
'symbols',
|
||||
'provider_exchange_mappings',
|
||||
'provider_mappings',
|
||||
'sync_status',
|
||||
// Legacy master tables (02-05)
|
||||
...LEGACY_MASTER_TABLES,
|
||||
// Security master tables (34)
|
||||
...SECURITY_MASTER_TABLES,
|
||||
// Research tables (06-33, including representatives from 12, 16, 20, 22, 28, 30)
|
||||
'backtests',
|
||||
'backtest_results',
|
||||
|
|
@ -155,7 +176,7 @@ describe.skipIf(!url)('fresh PostgreSQL database schema', () => {
|
|||
expect(await f.hasColumn('backtest_results', 'canonical_result')).toBe(true);
|
||||
});
|
||||
|
||||
test('Case B: master track creates master tables, records exact 5 files, and is idempotent', async () => {
|
||||
test('Case B: master track creates master tables, records exact 6 files, and is idempotent', async () => {
|
||||
const f = await createIsolatedFixture();
|
||||
|
||||
const first = await runPostgresMigrations(f.postgres, { track: 'master' });
|
||||
|
|
@ -163,13 +184,7 @@ describe.skipIf(!url)('fresh PostgreSQL database schema', () => {
|
|||
expect(await f.recorded()).toEqual(MASTER_FILES);
|
||||
|
||||
const createdTables = new Set(await f.tables());
|
||||
for (const table of [
|
||||
'exchanges',
|
||||
'symbols',
|
||||
'provider_exchange_mappings',
|
||||
'provider_mappings',
|
||||
'sync_status',
|
||||
]) {
|
||||
for (const table of [...LEGACY_MASTER_TABLES, ...SECURITY_MASTER_TABLES]) {
|
||||
expect(createdTables.has(table)).toBe(true);
|
||||
}
|
||||
expect(await f.hasColumn('exchanges', 'visible')).toBe(true);
|
||||
|
|
@ -186,7 +201,7 @@ describe.skipIf(!url)('fresh PostgreSQL database schema', () => {
|
|||
await f.pool.query(readFileSync(join(initDir, file), 'utf8'));
|
||||
}
|
||||
|
||||
const expected = [...MASTER_FILES, ...RESEARCH_FILES];
|
||||
const expected = [...MASTER_FILES, ...RESEARCH_FILES].sort();
|
||||
const first = await runPostgresMigrations(f.postgres, { track: 'all' });
|
||||
expect(first).toEqual(expected);
|
||||
|
||||
|
|
@ -196,6 +211,11 @@ describe.skipIf(!url)('fresh PostgreSQL database schema', () => {
|
|||
expect(recorded).not.toContain(excluded);
|
||||
}
|
||||
|
||||
const createdTables = new Set(await f.tables());
|
||||
for (const table of [...LEGACY_MASTER_TABLES, ...SECURITY_MASTER_TABLES]) {
|
||||
expect(createdTables.has(table)).toBe(true);
|
||||
}
|
||||
|
||||
const second = await runPostgresMigrations(f.postgres, { track: 'all' });
|
||||
expect(second).toEqual([]);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue