Files
online-backend/db/migrations/20260716170338_activity_logs.up.sql
2026-07-16 17:53:45 +05:00

19 lines
852 B
SQL

CREATE TABLE IF NOT EXISTS activity_logs (
id bigserial PRIMARY KEY,
user_id bigint,
method character varying(10) NOT NULL DEFAULT '',
path character varying(255) NOT NULL DEFAULT '',
module character varying(100) NOT NULL DEFAULT '',
action character varying(50) NOT NULL DEFAULT '',
status_code integer NOT NULL DEFAULT 0,
request_body jsonb,
ip character varying(50) NOT NULL DEFAULT '',
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
CONSTRAINT activity_logs_user_id_fkey
FOREIGN KEY ("user_id") REFERENCES users(id)
);
CREATE INDEX IF NOT EXISTS idx_activity_logs_user_id ON activity_logs(user_id);
CREATE INDEX IF NOT EXISTS idx_activity_logs_module ON activity_logs(module);
CREATE INDEX IF NOT EXISTS idx_activity_logs_created_at ON activity_logs(created_at);