CREATE TABLE "shell_audit_events" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "user_id" uuid NOT NULL, "event" text NOT NULL, "channel" text, "tab" text, "ip" text, "user_agent" text, "detail" jsonb, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint ALTER TABLE "shell_audit_events" ADD CONSTRAINT "shell_audit_events_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint CREATE INDEX "idx_shell_audit_user_time" ON "shell_audit_events" USING btree ("user_id","created_at");