CREATE TABLE "notification_rules" ( "id" text PRIMARY KEY NOT NULL, "key" text NOT NULL, "event" text DEFAULT 'assignment.created' NOT NULL, "offset_days" integer NOT NULL, "send_at_local_time" text DEFAULT '09:00' NOT NULL, "channel_set" text DEFAULT 'email' NOT NULL, "applies_to_service_id" text, "active" boolean DEFAULT true NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone, CONSTRAINT "notification_rules_key_unique" UNIQUE("key") ); --> statement-breakpoint ALTER TABLE "notification_rules" ADD CONSTRAINT "notification_rules_applies_to_service_id_services_id_fk" FOREIGN KEY ("applies_to_service_id") REFERENCES "public"."services"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint CREATE INDEX "notification_rules_active_idx" ON "notification_rules" USING btree ("active");