Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- Temporarily drop immutability trigger to allow update
DROP TRIGGER IF EXISTS trg_audit_records_enforce_immutability ON audit_records;

-- Convert empty string org_name values back to NULL
UPDATE audit_records
SET org_name = NULL
WHERE org_name = '';

-- Recreate immutability trigger
CREATE TRIGGER trg_audit_records_enforce_immutability
BEFORE UPDATE ON audit_records
FOR EACH ROW EXECUTE FUNCTION prevent_audit_record_updates();

-- Restore partial index condition to original
DROP INDEX IF EXISTS idx_audit_records_org_name;
CREATE INDEX idx_audit_records_org_name
ON audit_records(org_name, occurred_at DESC)
WHERE org_name IS NOT NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- Temporarily drop immutability trigger to allow update
DROP TRIGGER IF EXISTS trg_audit_records_enforce_immutability ON audit_records;

-- Convert all NULL org_name values to empty strings
UPDATE audit_records
SET org_name = ''
WHERE org_name IS NULL;

-- Recreate immutability trigger
CREATE TRIGGER trg_audit_records_enforce_immutability
BEFORE UPDATE ON audit_records
FOR EACH ROW EXECUTE FUNCTION prevent_audit_record_updates();

-- Update partial index condition to exclude both NULL and empty strings
DROP INDEX IF EXISTS idx_audit_records_org_name;
CREATE INDEX idx_audit_records_org_name
ON audit_records(org_name, occurred_at DESC)
WHERE org_name IS NOT NULL AND org_name != '';
Loading