Fix filing taxonomy schema mismatch by adding explicit column verification
The filing_taxonomy_snapshot table was missing parser_engine and related columns on databases created before the taxonomy surface sidecar migration. This caused filing sync workflows to fail with 'table has no column named parser_engine'. Changes: - Add TAXONOMY_SNAPSHOT_REQUIRED_COLUMNS constant for required columns - Add verifyCriticalSchema() to fail fast at startup if schema is incompatible - Reorder ensureTaxonomySnapshotCompat to check table existence before column ops - Add explicit column verification after ALTER TABLE attempts - Add regression tests for missing column detection Fixes #2
This commit is contained in:
@@ -199,4 +199,35 @@ describe('sqlite schema compatibility bootstrap', () => {
|
||||
|
||||
client.close();
|
||||
});
|
||||
|
||||
it('throws on missing parser_engine column when verifyCriticalSchema is called', () => {
|
||||
const client = new Database(':memory:');
|
||||
client.exec('PRAGMA foreign_keys = ON;');
|
||||
|
||||
applyMigration(client, '0000_cold_silver_centurion.sql');
|
||||
applyMigration(client, '0005_financial_taxonomy_v3.sql');
|
||||
|
||||
expect(__dbInternals.hasTable(client, 'filing_taxonomy_snapshot')).toBe(true);
|
||||
expect(__dbInternals.hasColumn(client, 'filing_taxonomy_snapshot', 'parser_engine')).toBe(false);
|
||||
|
||||
expect(() => __dbInternals.verifyCriticalSchema(client)).toThrow(
|
||||
/filing_taxonomy_snapshot is missing columns: parser_engine/
|
||||
);
|
||||
|
||||
client.close();
|
||||
});
|
||||
|
||||
it('verifyCriticalSchema passes when all required columns exist', () => {
|
||||
const client = new Database(':memory:');
|
||||
client.exec('PRAGMA foreign_keys = ON;');
|
||||
|
||||
applyMigration(client, '0000_cold_silver_centurion.sql');
|
||||
applyMigration(client, '0005_financial_taxonomy_v3.sql');
|
||||
|
||||
__dbInternals.ensureLocalSqliteSchema(client);
|
||||
|
||||
expect(() => __dbInternals.verifyCriticalSchema(client)).not.toThrow();
|
||||
|
||||
client.close();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user