Add compliance controls

This commit is contained in:
ZacharyZhang-NY committed 2026-05-23 17:25:29 -04:00
1 parent 78dbcbe7ce
commit 38c68ca4af
19 files changed
+882 -7

No files matched your search

@@ -0,0 +1,47 @@
export const complianceControlsSchema = `
alter table chat_spaces add column retention_policy text not null default 'standard_365d';
create table if not exists compliance_exports (
id text primary key,
org_id text not null references organizations(id) on delete cascade,
subject_type text not null,
subject_id text not null,
export_type text not null,
state text not null,
payload_json text not null,
requested_by_employee_id text references employees(id) on delete set null,
created_at text not null,
completed_at text
);
create table if not exists legal_holds (
id text primary key,
org_id text not null references organizations(id) on delete cascade,
entity_type text not null,
entity_id text not null,
reason text not null,
created_by_employee_id text references employees(id) on delete set null,
active integer not null,
created_at text not null,
released_at text
);
create table if not exists retention_freezes (
id text primary key,
org_id text not null references organizations(id) on delete cascade,
scope_type text not null,
scope_id text not null,
reason text not null,
created_by_employee_id text references employees(id) on delete set null,
active integer not null,
created_at text not null,
released_at text
);
create index if not exists idx_compliance_exports_org_created on compliance_exports(org_id, created_at);
create index if not exists idx_legal_holds_org_entity on legal_holds(org_id, entity_type, entity_id, active);
create index if not exists idx_retention_freezes_org_scope on retention_freezes(org_id, scope_type, scope_id, active);
insert into schema_migrations(version, name, applied_at)
values (12, 'compliance_controls', datetime('now'));
`;
@@ -10,6 +10,7 @@ import { providerHealthSchema } from "./migrations/008-provider-health";
import { socialGovernanceSchema } from "./migrations/009-social-governance";
import { fileHandoffSecuritySchema } from "./migrations/010-file-handoff-security";
import { boardInterventionSchema } from "./migrations/011-board-interventions";
import { complianceControlsSchema } from "./migrations/012-compliance-controls";
interface Migration {
version: number;
@@ -29,6 +30,7 @@ const MIGRATIONS: Migration[] = [
{ version: 9, name: "social_governance", sql: socialGovernanceSchema },
{ version: 10, name: "file_handoff_security", sql: fileHandoffSecuritySchema },
{ version: 11, name: "board_interventions", sql: boardInterventionSchema },
{ version: 12, name: "compliance_controls", sql: complianceControlsSchema },
];
const SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1].version;