mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
feat: implement SQLite backup & data integrity plan (Phases 2-4)
This commit is contained in:
16
app/migrations/applied/026_audit_log.sql
Normal file
16
app/migrations/applied/026_audit_log.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
-- Migration 026: create audit_log table for data-level audit trail
|
||||
-- Records before/after snapshots of every row mutation on core tables.
|
||||
-- Admin actions are already logged separately via admin_audit_log.
|
||||
CREATE TABLE IF NOT EXISTS audit_log (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
timestamp TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
actor TEXT NOT NULL,
|
||||
action TEXT NOT NULL CHECK(action IN ('INSERT','UPDATE','DELETE')),
|
||||
table_name TEXT NOT NULL,
|
||||
record_id INTEGER,
|
||||
old_data TEXT,
|
||||
new_data TEXT
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_audit_log_table_record ON audit_log(table_name, record_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_audit_log_timestamp ON audit_log(timestamp);
|
||||
Reference in New Issue
Block a user