Skip to content

Commit 8a0c1d4

Browse files
authored
feat: add audit_field_changes table (#4157)
Signed-off-by: anilb <epipav@gmail.com>
1 parent d9e2c48 commit 8a0c1d4

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

backend/src/osspckgs/migrations/V1779710880__initial_schema.sql

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,28 @@ PARTITION BY RANGE (end_date);
794794

795795
CREATE INDEX ON downloads_last_30d (purl, end_date DESC);
796796

797+
-- ============================================================
798+
-- AUDIT — per-purl field-change log
799+
--
800+
-- Append-only log of field-level changes. Each row records the set of
801+
-- 'table.column' tokens that were actually mutated for a given purl during one
802+
-- worker write pass. Rows with no real changes are not written (caller skips
803+
-- the insert when changed_fields is empty).
804+
-- ============================================================
805+
CREATE TABLE audit_field_changes (
806+
id bigserial PRIMARY KEY,
807+
worker text NOT NULL,
808+
purl text NOT NULL,
809+
logged_at timestamptz NOT NULL DEFAULT NOW(),
810+
changed_fields text[] NOT NULL
811+
);
812+
813+
CREATE INDEX ON audit_field_changes (purl, logged_at DESC);
814+
815+
CREATE INDEX ON audit_field_changes (worker, logged_at DESC);
816+
817+
CREATE INDEX ON audit_field_changes USING gin (changed_fields);
818+
797819
-- ============================================================
798820
-- CRITICALITY RANKING FUNCTION
799821
-- ============================================================

0 commit comments

Comments
 (0)