| 1 | CREATE TYPE "public"."change_request_status" AS ENUM('pending', 'accepted', 'rejected');--> statement-breakpoint |
| 2 | CREATE TYPE "public"."status |
| 3 | CREATE TYPE "public"."thread_status |
| 4 | CREATE TABLE "media" ( |
| 5 | "id" text PRIMARY KEY |
| 6 | "organization_id" text NOT NULL |
| 7 | "uploaded_by_member_id" text, |
| 8 | "name" text NOT NULL |
| 9 | "key" text NOT NULL |
| 10 | "url" text NOT NULL |
| 11 | "content_type" text NOT NULL |
| 12 | "size" integer NOT NULL |
| 13 | "created_at" timestamp DEFAULT |
| 14 | CONSTRAINT "media_key_unique" UNIQUE |
| 15 | ); |
| 16 | --> statement-breakpoint |
| 17 | CREATE TABLE "requirement_change_requests" ( |
| 18 | "id" text PRIMARY KEY |
| 19 | "requirement_id" text NOT NULL |
| 20 | "requested_by_member_id" text, |
| 21 | "description" text NOT NULL |
| 22 | "referenced_thread_ids" text[], |
| 23 | "status" "change_request_status" DEFAULT |
| 24 | "created_at" timestamp DEFAULT |
| 25 | "resolved_at" timestamp |
| 26 | ); |
| 27 | --> statement-breakpoint |
| 28 | CREATE TABLE "requirement_recipients" ( |
| 29 | "id" text PRIMARY KEY |
| 30 | "requirement_id" text NOT NULL |
| 31 | "client_member_id" text NOT NULL |
| 32 | "sent_at" timestamp DEFAULT |
| 33 | ); |
| 34 | --> statement-breakpoint |
| 35 | CREATE TABLE "requirement_signatures" ( |
| 36 | "id" text PRIMARY KEY |
| 37 | "requirement_id" text NOT NULL |
| 38 | "client_member_id" text NOT NULL |
| 39 | "signed_at" timestamp DEFAULT |
| 40 | "media_id" text |
| 41 | ); |
| 42 | --> statement-breakpoint |
| 43 | CREATE TABLE "requirement_thread_messages" ( |
| 44 | "id" text PRIMARY KEY |
| 45 | "thread_id" text NOT NULL |
| 46 | "author_member_id" text, |
| 47 | "body" text NOT NULL |
| 48 | "created_at" timestamp DEFAULT |
| 49 | ); |
| 50 | --> statement-breakpoint |
| 51 | CREATE TABLE "requirement_threads" ( |
| 52 | "id" text PRIMARY KEY |
| 53 | "requirement_id" text NOT NULL |
| 54 | "selected_text" text NOT NULL |
| 55 | "context_before" text, |
| 56 | "context_after" text, |
| 57 | "status" "thread_status" DEFAULT |
| 58 | "created_by_member_id" text, |
| 59 | "created_at" timestamp DEFAULT |
| 60 | ); |
| 61 | --> statement-breakpoint |
| 62 | CREATE TABLE "requirements" ( |
| 63 | "id" text PRIMARY KEY |
| 64 | "project_id" text NOT NULL |
| 65 | "author_id" text, |
| 66 | "slug" text NOT NULL |
| 67 | "title" text NOT NULL |
| 68 | "body" text DEFAULT |
| 69 | "status" "status" DEFAULT |
| 70 | "created_at" timestamp DEFAULT |
| 71 | "updated_at" timestamp DEFAULT |
| 72 | CONSTRAINT "requirements_project_id_slug_unique" UNIQUE |
| 73 | ); |
| 74 | --> statement-breakpoint |
| 75 | ALTER TABLE "media" ADD |
| 76 | ALTER TABLE "requirement_change_requests" ADD |
| 77 | ALTER TABLE "requirement_change_requests" ADD |
| 78 | ALTER TABLE "requirement_recipients" ADD |
| 79 | ALTER TABLE "requirement_recipients" ADD |
| 80 | ALTER TABLE "requirement_signatures" ADD |
| 81 | ALTER TABLE "requirement_signatures" ADD |
| 82 | ALTER TABLE "requirement_signatures" ADD |
| 83 | ALTER TABLE "requirement_thread_messages" ADD |
| 84 | ALTER TABLE "requirement_thread_messages" ADD |
| 85 | ALTER TABLE "requirement_threads" ADD |
| 86 | ALTER TABLE "requirement_threads" ADD |
| 87 | ALTER TABLE "requirements" ADD |
| 88 | ALTER TABLE "requirements" ADD |
| 89 | CREATE INDEX "requirement_threads_requirement_id_idx" ON |
| 90 | CREATE INDEX "requirements_project_id_idx" ON |