CREATE TABLE "activity_log" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "household_id" uuid NOT NULL, "entity_type" text NOT NULL, "entity_id" uuid NOT NULL, "actor_id" uuid NOT NULL, "action" text NOT NULL, "payload" jsonb, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint ALTER TABLE "activity_log" ADD CONSTRAINT "activity_log_household_id_households_id_fk" FOREIGN KEY ("household_id") REFERENCES "public"."households"("id") ON DELETE cascade ON UPDATE no action; --> statement-breakpoint ALTER TABLE "activity_log" ADD CONSTRAINT "activity_log_actor_id_users_id_fk" FOREIGN KEY ("actor_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action; --> statement-breakpoint CREATE INDEX "activity_log_household_created_idx" ON "activity_log" USING btree ("household_id","created_at");