From fa3bc592d1db18df4fc4da286f9e09d9e9959201 Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Tue, 17 Mar 2026 15:32:20 +0100 Subject: [PATCH] feat: add Flyway V9 (thresholds) and V10 (audit_log) migrations --- .../resources/db/migration/V10__audit_log.sql | 18 ++++++++++++++++++ .../db/migration/V9__admin_thresholds.sql | 7 +++++++ 2 files changed, 25 insertions(+) create mode 100644 cameleer3-server-app/src/main/resources/db/migration/V10__audit_log.sql create mode 100644 cameleer3-server-app/src/main/resources/db/migration/V9__admin_thresholds.sql diff --git a/cameleer3-server-app/src/main/resources/db/migration/V10__audit_log.sql b/cameleer3-server-app/src/main/resources/db/migration/V10__audit_log.sql new file mode 100644 index 00000000..d10230a6 --- /dev/null +++ b/cameleer3-server-app/src/main/resources/db/migration/V10__audit_log.sql @@ -0,0 +1,18 @@ +CREATE TABLE audit_log ( + id BIGSERIAL PRIMARY KEY, + timestamp TIMESTAMPTZ NOT NULL DEFAULT now(), + username TEXT NOT NULL, + action TEXT NOT NULL, + category TEXT NOT NULL, + target TEXT, + detail JSONB, + result TEXT NOT NULL, + ip_address TEXT, + user_agent TEXT +); + +CREATE INDEX idx_audit_log_timestamp ON audit_log (timestamp DESC); +CREATE INDEX idx_audit_log_username ON audit_log (username); +CREATE INDEX idx_audit_log_category ON audit_log (category); +CREATE INDEX idx_audit_log_action ON audit_log (action); +CREATE INDEX idx_audit_log_target ON audit_log (target); diff --git a/cameleer3-server-app/src/main/resources/db/migration/V9__admin_thresholds.sql b/cameleer3-server-app/src/main/resources/db/migration/V9__admin_thresholds.sql new file mode 100644 index 00000000..9b618c97 --- /dev/null +++ b/cameleer3-server-app/src/main/resources/db/migration/V9__admin_thresholds.sql @@ -0,0 +1,7 @@ +CREATE TABLE admin_thresholds ( + id INTEGER PRIMARY KEY DEFAULT 1, + config JSONB NOT NULL DEFAULT '{}', + updated_at TIMESTAMPTZ NOT NULL DEFAULT now(), + updated_by TEXT NOT NULL, + CONSTRAINT single_row CHECK (id = 1) +);