CREATE TABLE "evidence_capture_events" ( "id" text PRIMARY KEY NOT NULL, "target_type" text NOT NULL, "target_id" text NOT NULL, "node_id" text, "capture_id" text NOT NULL, "event" text NOT NULL, "out" text, "phase" text, "round" text, "kind" text, "device" text, "intent" text, "expect_moment" text, "verdict" text, "issues" text, "duration_s" double precision, "file_bytes" bigint, "probe" text, "attempt" bigint, "retry_allowed" bigint, "reason" text, "stderr_tail" text, "ts" bigint NOT NULL, "ingested_at" bigint NOT NULL ); --> statement-breakpoint CREATE TABLE "evidence_media" ( "owner_kind" text NOT NULL, "owner_id" text NOT NULL, "name" text NOT NULL, "url" text NOT NULL, "content_type" text, "size" bigint, "uploaded_at" bigint NOT NULL, CONSTRAINT "evidence_media_owner_kind_owner_id_name_pk" PRIMARY KEY("owner_kind","owner_id","name") ); --> statement-breakpoint CREATE TABLE "features" ( "id" text PRIMARY KEY NOT NULL, "title" text NOT NULL, "description" text DEFAULT '' NOT NULL, "platform" text NOT NULL, "remark" text, "review_feedback" text, "execution_plan" text, "regen_context" text, "workspace_path" text, "pinned" bigint DEFAULT 0 NOT NULL, "status" text DEFAULT 'initializing' NOT NULL, "priority_key" double precision NOT NULL, "watchers" text, "created_at" bigint NOT NULL, "started_at" bigint, "finished_at" bigint, "duration_ms" bigint, "total_duration_ms" bigint, "branch_name" text, "mr_url" text, "log_path" text, "eval_log_path" text, "before_evidence_path" text, "after_evidence_path" text, "failure_reason" text, "attempts" bigint DEFAULT 0 NOT NULL, "executor_node_id" text, "status_changed_at" bigint, "review_history" text, "creator_email" text, "readable_report_html" text, "readable_report_generated_at" bigint, "readable_report_error" text, "readable_report_prompt_id" text, "readable_report_prompt_name" text, "clusters" text, "lang" text, "linked_feature_id" text, "port_source_id" text, "attachments" text ); --> statement-breakpoint CREATE TABLE "fix_report_versions" ( "task_id" text NOT NULL, "round" bigint NOT NULL, "markdown" text NOT NULL, "created_at" bigint NOT NULL, CONSTRAINT "fix_report_versions_task_id_round_pk" PRIMARY KEY("task_id","round") ); --> statement-breakpoint CREATE TABLE "lark_users" ( "lark_user_id" text PRIMARY KEY NOT NULL, "email" text, "name" text, "created_at" bigint NOT NULL, "updated_at" bigint NOT NULL ); --> statement-breakpoint CREATE TABLE "logs" ( "id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "logs_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1), "task_id" text NOT NULL, "ts" bigint NOT NULL, "level" text NOT NULL, "stage" text DEFAULT '' NOT NULL, "message" text NOT NULL ); --> statement-breakpoint CREATE TABLE "node_clusters" ( "node_id" text NOT NULL, "cluster" text NOT NULL, CONSTRAINT "node_clusters_node_id_cluster_pk" PRIMARY KEY("node_id","cluster") ); --> statement-breakpoint CREATE TABLE "nodes" ( "id" text PRIMARY KEY NOT NULL, "base_url" text NOT NULL, "platform" text NOT NULL, "status" text DEFAULT 'online' NOT NULL, "last_seen_at" bigint NOT NULL, "eval_in_flight" bigint DEFAULT 0 NOT NULL, "eval_capacity" bigint DEFAULT 0 NOT NULL, "fix_in_flight" bigint DEFAULT 0 NOT NULL, "fix_capacity" bigint DEFAULT 0 NOT NULL, "version" text, "created_at" bigint NOT NULL, "boot_id" text ); --> statement-breakpoint CREATE TABLE "readable_batch_jobs" ( "id" text PRIMARY KEY NOT NULL, "status" text DEFAULT 'running' NOT NULL, "prompt_id" text, "prompt_name" text, "prompt_template" text NOT NULL, "items" text NOT NULL, "total" bigint DEFAULT 0 NOT NULL, "processed" bigint DEFAULT 0 NOT NULL, "succeeded" bigint DEFAULT 0 NOT NULL, "failed" bigint DEFAULT 0 NOT NULL, "error" text, "created_by" text, "started_at" bigint NOT NULL, "finished_at" bigint ); --> statement-breakpoint CREATE TABLE "readable_prompts" ( "id" text PRIMARY KEY NOT NULL, "name" text NOT NULL, "template" text NOT NULL, "notes" text, "kind" text DEFAULT 'both' NOT NULL, "created_at" bigint NOT NULL, "created_by" text, "archived" bigint DEFAULT 0 NOT NULL ); --> statement-breakpoint CREATE TABLE "readable_report_runs" ( "id" text PRIMARY KEY NOT NULL, "target_type" text NOT NULL, "target_id" text NOT NULL, "prompt_id" text, "prompt_name" text, "prompt_template" text NOT NULL, "status" text DEFAULT 'running' NOT NULL, "html" text, "error" text, "model" text, "node_id" text, "duration_ms" bigint, "created_by" text, "created_at" bigint NOT NULL, "finished_at" bigint, "is_current" bigint DEFAULT 0 NOT NULL, "batch_id" text ); --> statement-breakpoint CREATE TABLE "readable_sources" ( "target_type" text NOT NULL, "target_id" text NOT NULL, "markdown" text NOT NULL, "fetched_at" bigint NOT NULL, CONSTRAINT "readable_sources_target_type_target_id_pk" PRIMARY KEY("target_type","target_id") ); --> statement-breakpoint CREATE TABLE "security" ( "id" text PRIMARY KEY NOT NULL, "title" text NOT NULL, "description" text DEFAULT '' NOT NULL, "review_spec" text DEFAULT '' NOT NULL, "repro_spec" text DEFAULT '' NOT NULL, "target_ref" text, "platform" text NOT NULL, "remark" text, "review_feedback" text, "review_history" text, "execution_plan" text, "regen_context" text, "workspace_path" text, "pinned" bigint DEFAULT 0 NOT NULL, "status" text DEFAULT 'initializing' NOT NULL, "priority_key" double precision NOT NULL, "watchers" text, "creator_email" text, "created_at" bigint NOT NULL, "started_at" bigint, "finished_at" bigint, "duration_ms" bigint, "total_duration_ms" bigint, "branch_name" text, "mr_url" text, "log_path" text, "eval_log_path" text, "before_evidence_path" text, "after_evidence_path" text, "failure_reason" text, "attempts" bigint DEFAULT 0 NOT NULL, "executor_node_id" text, "readable_report_html" text, "readable_report_generated_at" bigint, "readable_report_error" text, "clusters" text, "status_changed_at" bigint, "readable_report_prompt_id" text, "readable_report_prompt_name" text, "lang" text ); --> statement-breakpoint CREATE TABLE "settings" ( "key" text PRIMARY KEY NOT NULL, "value" text NOT NULL, "updated_at" bigint NOT NULL ); --> statement-breakpoint CREATE TABLE "task_transitions" ( "id" text PRIMARY KEY NOT NULL, "kind" text NOT NULL, "target_id" text NOT NULL, "from_status" text, "to_status" text NOT NULL, "round" bigint, "node_id" text, "source" text NOT NULL, "ts" bigint NOT NULL ); --> statement-breakpoint CREATE TABLE "tasks" ( "id" text PRIMARY KEY NOT NULL, "meego_id" text NOT NULL, "meego_url" text NOT NULL, "title" text NOT NULL, "description" text DEFAULT '' NOT NULL, "repro_steps" text DEFAULT '' NOT NULL, "bug_type" text NOT NULL, "platform" text NOT NULL, "difficulty" text NOT NULL, "steps_clarity" text NOT NULL, "remark" text, "review_feedback" text, "execution_plan" text, "regen_context" text, "workspace_path" text, "pinned" bigint DEFAULT 0 NOT NULL, "status" text DEFAULT 'initializing' NOT NULL, "priority_key" double precision NOT NULL, "created_at" bigint NOT NULL, "started_at" bigint, "finished_at" bigint, "duration_ms" bigint, "branch_name" text, "mr_url" text, "log_path" text, "before_evidence_path" text, "after_evidence_path" text, "failure_reason" text, "attempts" bigint DEFAULT 0 NOT NULL, "total_duration_ms" bigint, "creator_email" text, "creator_lark_id" text, "creator_name" text, "creator_avatar" text, "eval_log_path" text, "watchers" text, "executor_node_id" text, "mr_state" text, "mr_merged_at" bigint, "meego_state" text, "mr_synced_at" bigint, "status_changed_at" bigint, "lang" text DEFAULT 'zh' NOT NULL, "attachments" text, "review_history" text, "fixed_risk" bigint, "readable_report_html" text, "readable_report_generated_at" bigint, "readable_report_error" text, "readable_report_prompt_id" text, "readable_report_prompt_name" text, "clusters" text, CONSTRAINT "tasks_meegoId_unique" UNIQUE("meego_id") ); --> statement-breakpoint CREATE TABLE "watcher_names" ( "wkey" text PRIMARY KEY NOT NULL, "name" text NOT NULL, "updated_at" bigint NOT NULL ); --> statement-breakpoint ALTER TABLE "fix_report_versions" ADD CONSTRAINT "fix_report_versions_task_id_tasks_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."tasks"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "logs" ADD CONSTRAINT "logs_task_id_tasks_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."tasks"("id") ON DELETE cascade ON UPDATE no action;