Files
goods/migrations/0005_admin.up.sql
oyaegeli98668 d90a539e6b
CI / Go (api) (pull_request) Failing after 18s
CI / Python (ingestion) (pull_request) Successful in 7s
CI / Migrations (postgres) (pull_request) Failing after 18s
feat(admin): 运营后台(登录/查看/审核编辑/补全)+ 写入API + 审计留痕
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-06-20 02:53:30 +00:00

23 lines
905 B
SQL

-- Admin console support: manual edit provenance + audit log.
-- Manual-entry source used to record field-level provenance for operator edits.
INSERT INTO source (name, homepage, license, trust_weight, notes)
VALUES ('manual', NULL, 'proprietary', 0.90, '运营人工录入/补全')
ON CONFLICT (name) DO NOTHING;
-- Audit trail: every admin write records actor, action, entity and before/after.
CREATE TABLE IF NOT EXISTS audit_log (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
actor TEXT NOT NULL,
action TEXT NOT NULL,
entity TEXT NOT NULL,
entity_id UUID,
fields TEXT[] NOT NULL DEFAULT '{}',
before JSONB,
after JSONB,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_audit_entity ON audit_log (entity, entity_id);
CREATE INDEX IF NOT EXISTS idx_audit_created ON audit_log (created_at DESC);