harbor/make/migrations/postgresql/0160_2.13.0_schema.up.sql
stonezdj(Daojun Zhang) b0c74a0584
Add swagger api and audit_log_ext table model (#21360)
add auditlog-ext related api in swagger
  add audit_log_ext table

Signed-off-by: stonezdj <stone.zhang@broadcom.com>
2025-01-03 06:11:09 +00:00

24 lines
959 B
SQL

ALTER TABLE p2p_preheat_policy DROP COLUMN IF EXISTS scope;
ALTER TABLE p2p_preheat_policy ADD COLUMN IF NOT EXISTS extra_attrs text;
CREATE TABLE IF NOT EXISTS audit_log_ext
(
id BIGSERIAL PRIMARY KEY NOT NULL,
project_id BIGINT,
operation VARCHAR(50) NULL,
resource_type VARCHAR(50) NULL,
resource VARCHAR(50) NULL,
username VARCHAR(50) NULL,
op_desc VARCHAR(500) NULL,
op_result BOOLEAN DEFAULT true,
payload TEXT NULL,
source_ip VARCHAR(50) NULL,
op_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- add index to the audit_log_ext table
CREATE INDEX IF NOT EXISTS idx_audit_log_ext_op_time ON audit_log_ext (op_time);
CREATE INDEX IF NOT EXISTS idx_audit_log_ext_project_id_optime ON audit_log_ext (project_id, op_time);
CREATE INDEX IF NOT EXISTS idx_audit_log_ext_project_id_resource_type ON audit_log_ext (project_id, resource_type);
CREATE INDEX IF NOT EXISTS idx_audit_log_ext_project_id_operation ON audit_log_ext (project_id, operation);