diff --git a/backend-compliance/migrations/042_company_profile_project_id.sql b/backend-compliance/migrations/042_company_profile_project_id.sql index bdcab38..23f933c 100644 --- a/backend-compliance/migrations/042_company_profile_project_id.sql +++ b/backend-compliance/migrations/042_company_profile_project_id.sql @@ -59,7 +59,18 @@ BEGIN END IF; END $$; --- 7. Add audit log project_id column too +-- 7. Create audit table if not exists, then add project_id +CREATE TABLE IF NOT EXISTS compliance_company_profile_audit ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + tenant_id VARCHAR(255) NOT NULL, + action VARCHAR(20) NOT NULL, + changed_fields JSONB, + changed_by VARCHAR(255), + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +CREATE INDEX IF NOT EXISTS idx_company_profile_audit_tenant ON compliance_company_profile_audit(tenant_id); + ALTER TABLE compliance_company_profile_audit ADD COLUMN IF NOT EXISTS project_id UUID;