15 lines
810 B
SQL
15 lines
810 B
SQL
CREATE TABLE "audit_logs" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"owner_user_id" uuid NOT NULL,
|
|
"actor_device_id" uuid,
|
|
"action" varchar(128) NOT NULL,
|
|
"target_type" varchar(64) NOT NULL,
|
|
"target_id" varchar(255) NOT NULL,
|
|
"metadata" jsonb DEFAULT 'null'::jsonb,
|
|
"ip_address" text,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "audit_logs" ADD CONSTRAINT "audit_logs_owner_user_id_users_id_fk" FOREIGN KEY ("owner_user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "audit_logs" ADD CONSTRAINT "audit_logs_actor_device_id_devices_id_fk" FOREIGN KEY ("actor_device_id") REFERENCES "public"."devices"("id") ON DELETE no action ON UPDATE no action;
|