Add database migration to merge findings

Merge nonconformities and continual_improvements tables into a
unified findings table with kind (NONCONFORMITY, OBSERVATION,
EXCEPTION), status, and priority enums. Create findings_audits
junction table for the many-to-many audit relationship.

The migration generates new FND-XXX reference IDs per organization,
migrates both live and snapshot records preserving source_id links,
and carries over audit associations to the junction table.

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-03-17 00:16:21 +01:00
parent 72d2f85ed2
commit 736436e997
2 changed files with 233 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
-- Add FINDINGS value to snapshots_type enum
-- This must be in its own migration because PostgreSQL requires the new enum
-- value to be committed before it can be used in DML statements.
ALTER TYPE snapshots_type ADD VALUE IF NOT EXISTS 'FINDINGS';