20 lines
1.3 KiB
TypeScript
20 lines
1.3 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { databaseMigrations } from '../../server/postgres/migration-catalog';
|
|
|
|
describe('PostgreSQL regulatory mapping framework migration', () => {
|
|
it('adds a framework to mappings and decisions and a global consistency review table', () => {
|
|
const migration = databaseMigrations.find(item => item.version === '029');
|
|
expect(migration).toMatchObject({ version: '029', name: 'regulatory-mapping-framework' });
|
|
const sql = migration!.sql;
|
|
// Every existing row is an ISO mapping; only the two known frameworks are allowed.
|
|
expect(sql.match(/ADD COLUMN framework text NOT NULL DEFAULT 'iso27001' CHECK \(framework IN \('iso27001', 'bsi-kernel'\)\)/g)).toHaveLength(2);
|
|
expect(sql).toContain('UNIQUE (framework, rule_key, corpus_version, retrieval_version, prompt_version, model)');
|
|
expect(sql).toMatch(/assessor_regulatory_mapping_decisions_rule_control_idx[\s\S]*\(rule_key, framework, control_id/);
|
|
expect(sql).toContain('CREATE TABLE assessor_regulatory_consistency_reviews');
|
|
expect(sql).toContain("fingerprint text NOT NULL CHECK (fingerprint ~ '^[a-f0-9]{64}$')");
|
|
// Reviews are global per rule like decisions, and the migration never drops data.
|
|
expect(sql).not.toContain('project_id');
|
|
expect(sql).not.toMatch(/DROP TABLE|DELETE FROM|TRUNCATE/);
|
|
});
|
|
});
|