| 1 | CREATE TYPE "public"."notification_reason" AS ENUM('assigned', 'mentioned', 'team_mentioned', 'author', 'subscribed', 'watching');--> statement-breakpoint |
| 2 | CREATE TYPE "public"."repository_watch_level |
| 3 | CREATE TABLE "issue_subscription" ( |
| 4 | "user_id" text NOT NULL |
| 5 | "issue_id" text NOT NULL |
| 6 | "subscribed" boolean NOT NULL |
| 7 | "created_at" timestamp with time zone DEFAULT |
| 8 | CONSTRAINT "issue_subscription_user_id_issue_id_pk" PRIMARY KEY |
| 9 | ); |
| 10 | --> statement-breakpoint |
| 11 | CREATE TABLE "notification" ( |
| 12 | "id" text PRIMARY KEY |
| 13 | "user_id" text NOT NULL |
| 14 | "issue_id" text NOT NULL |
| 15 | "reason" "notification_reason" NOT NULL |
| 16 | "event_type" text NOT NULL |
| 17 | "actor_id" text, |
| 18 | "unread" boolean DEFAULT |
| 19 | "updated_at" timestamp (3 |
| 20 | ); |
| 21 | --> statement-breakpoint |
| 22 | CREATE TABLE "outbox_event" ( |
| 23 | "id" text PRIMARY KEY |
| 24 | "type" text NOT NULL |
| 25 | "repository_id" text NOT NULL |
| 26 | "actor_id" text, |
| 27 | "payload" jsonb NOT NULL, |
| 28 | "attempts" integer DEFAULT |
| 29 | "last_error" text, |
| 30 | "created_at" timestamp with time zone DEFAULT |
| 31 | "processed_at" timestamp with time zone |
| 32 | ); |
| 33 | --> statement-breakpoint |
| 34 | CREATE TABLE "repository_watch" ( |
| 35 | "user_id" text NOT NULL |
| 36 | "repository_id" text NOT NULL |
| 37 | "level" "repository_watch_level" NOT NULL |
| 38 | "created_at" timestamp with time zone DEFAULT |
| 39 | CONSTRAINT "repository_watch_user_id_repository_id_pk" PRIMARY KEY |
| 40 | ); |
| 41 | --> statement-breakpoint |
| 42 | ALTER TABLE "issue_subscription" ADD |
| 43 | ALTER TABLE "issue_subscription" ADD |
| 44 | ALTER TABLE "notification" ADD |
| 45 | ALTER TABLE "notification" ADD |
| 46 | ALTER TABLE "notification" ADD |
| 47 | ALTER TABLE "outbox_event" ADD |
| 48 | ALTER TABLE "outbox_event" ADD |
| 49 | ALTER TABLE "repository_watch" ADD |
| 50 | ALTER TABLE "repository_watch" ADD |
| 51 | CREATE INDEX "issue_subscription_issue_idx" ON |
| 52 | CREATE UNIQUE INDEX "notification_user_issue_idx" ON |
| 53 | CREATE INDEX "notification_user_updated_idx" ON |
| 54 | CREATE INDEX "outbox_event_pending_idx" ON |
| 55 | CREATE INDEX "repository_watch_repository_idx" ON |