18 lines
1000 B
SQL
18 lines
1000 B
SQL
CREATE TABLE "audit_log" (
|
|
"id" bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "audit_log_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1),
|
|
"actor_id" text NOT NULL,
|
|
"actor_label" text NOT NULL,
|
|
"action" varchar(64) NOT NULL,
|
|
"target_type" varchar(32) NOT NULL,
|
|
"target_id" text NOT NULL,
|
|
"scope" varchar(64),
|
|
"resulting_version" integer,
|
|
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE INDEX "audit_log_created_idx" ON "audit_log" USING btree ("created_at","id");--> statement-breakpoint
|
|
CREATE INDEX "audit_log_actor_created_idx" ON "audit_log" USING btree ("actor_id","created_at");--> statement-breakpoint
|
|
CREATE INDEX "audit_log_target_created_idx" ON "audit_log" USING btree ("target_type","target_id","created_at");--> statement-breakpoint
|
|
CREATE INDEX "audit_log_action_created_idx" ON "audit_log" USING btree ("action","created_at");
|