CREATE TABLE "fixed_costs" ( "id" text PRIMARY KEY NOT NULL, "household_id" text NOT NULL, "scope" "transaction_scope" DEFAULT 'household' NOT NULL, "child_id" text, "category_id" text, "label" text NOT NULL, "amount" numeric(12, 2) NOT NULL, "type" "transaction_type" DEFAULT 'expense' NOT NULL, "is_active" boolean DEFAULT true NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "monthly_transfers" ( "id" text PRIMARY KEY NOT NULL, "household_id" text NOT NULL, "month" text NOT NULL, "from_user_id" text NOT NULL, "to_user_id" text NOT NULL, "amount" numeric(12, 2) NOT NULL, "note" text, "created_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "transfer_line_items" ( "id" text PRIMARY KEY NOT NULL, "household_id" text NOT NULL, "label" text NOT NULL, "amount" numeric(12, 2) NOT NULL, "is_active" boolean DEFAULT true NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint ALTER TABLE "fixed_costs" ADD CONSTRAINT "fixed_costs_household_id_households_id_fk" FOREIGN KEY ("household_id") REFERENCES "public"."households"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "fixed_costs" ADD CONSTRAINT "fixed_costs_child_id_children_id_fk" FOREIGN KEY ("child_id") REFERENCES "public"."children"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint ALTER TABLE "fixed_costs" ADD CONSTRAINT "fixed_costs_category_id_categories_id_fk" FOREIGN KEY ("category_id") REFERENCES "public"."categories"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint ALTER TABLE "monthly_transfers" ADD CONSTRAINT "monthly_transfers_household_id_households_id_fk" FOREIGN KEY ("household_id") REFERENCES "public"."households"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "monthly_transfers" ADD CONSTRAINT "monthly_transfers_from_user_id_user_id_fk" FOREIGN KEY ("from_user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "monthly_transfers" ADD CONSTRAINT "monthly_transfers_to_user_id_user_id_fk" FOREIGN KEY ("to_user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "transfer_line_items" ADD CONSTRAINT "transfer_line_items_household_id_households_id_fk" FOREIGN KEY ("household_id") REFERENCES "public"."households"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint CREATE INDEX "fixed_costs_household_id_idx" ON "fixed_costs" USING btree ("household_id");--> statement-breakpoint CREATE INDEX "fixed_costs_scope_idx" ON "fixed_costs" USING btree ("scope");--> statement-breakpoint CREATE INDEX "monthly_transfers_household_id_idx" ON "monthly_transfers" USING btree ("household_id");--> statement-breakpoint CREATE INDEX "monthly_transfers_month_idx" ON "monthly_transfers" USING btree ("month");--> statement-breakpoint CREATE INDEX "transfer_line_items_household_id_idx" ON "transfer_line_items" USING btree ("household_id");