CREATE TABLE "sys"."channel_instance" ( "id" text PRIMARY KEY NOT NULL, "name" text NOT NULL, "kind" text NOT NULL, "address" text NOT NULL, "enabled" boolean DEFAULT true NOT NULL, "extract" jsonb DEFAULT '[]'::jsonb NOT NULL, "mapping" jsonb DEFAULT '[]'::jsonb NOT NULL, "fallback_position" text, "address_window_ms" integer DEFAULT 604800000 NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "sys"."outbound_mail" ( "id" text PRIMARY KEY NOT NULL, "thread_id" text NOT NULL, "from_addr" text NOT NULL, "to_addrs" jsonb NOT NULL, "cc_addrs" jsonb DEFAULT '[]'::jsonb NOT NULL, "subject" text NOT NULL, "body" text NOT NULL, "attachments" jsonb DEFAULT '[]'::jsonb NOT NULL, "sent_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "sys"."system_message" ( "id" text PRIMARY KEY NOT NULL, "kind" text NOT NULL, "staff_id" text NOT NULL, "position_id" text, "title" text NOT NULL, "body" text NOT NULL, "at" timestamp with time zone DEFAULT now() NOT NULL, "read_at" timestamp with time zone, "card" jsonb, "answer" jsonb, "event_ref" text ); --> statement-breakpoint CREATE INDEX "message_staff_idx" ON "sys"."system_message" USING btree ("staff_id","at");--> statement-breakpoint CREATE INDEX "message_unread_idx" ON "sys"."system_message" USING btree ("staff_id","read_at");