feat : comment feature
CI / Verify (push) Successful in 2m30s
CI / Build immutable images and deploy (push) Successful in 3m9s

This commit is contained in:
2026-10-08 01:40:08 +07:00 Unverified
parent 8c8815cda5
commit 5812d99715
65 changed files with 27013 additions and 10 deletions
+81
View File
@@ -0,0 +1,81 @@
CREATE TABLE "guides"."comment_attachment" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"comment_id" uuid NOT NULL,
"object_key" text NOT NULL,
"mime_type" text NOT NULL,
"byte_size" integer NOT NULL,
CONSTRAINT "comment_image_size" CHECK ("guides"."comment_attachment"."byte_size" > 0 and "guides"."comment_attachment"."byte_size" <= 10485760),
CONSTRAINT "comment_image_type" CHECK ("guides"."comment_attachment"."mime_type" in ('image/jpeg', 'image/png', 'image/webp'))
);
--> statement-breakpoint
CREATE TABLE "guides"."comment_reaction" (
"comment_id" uuid NOT NULL,
"user_id" text NOT NULL,
"value" integer NOT NULL,
CONSTRAINT "comment_reaction_comment_id_user_id_pk" PRIMARY KEY("comment_id","user_id"),
CONSTRAINT "comment_reaction_value" CHECK ("guides"."comment_reaction"."value" in (-1, 1))
);
--> statement-breakpoint
CREATE TABLE "guides"."comment_revision_attachment" (
"revision_id" uuid NOT NULL,
"attachment_id" uuid NOT NULL,
"position" integer NOT NULL,
CONSTRAINT "comment_revision_attachment_revision_id_attachment_id_pk" PRIMARY KEY("revision_id","attachment_id"),
CONSTRAINT "comment_attachment_position" CHECK ("guides"."comment_revision_attachment"."position" >= 0 and "guides"."comment_revision_attachment"."position" < 5)
);
--> statement-breakpoint
CREATE TABLE "guides"."comment_revision" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"comment_id" uuid NOT NULL,
"version" integer NOT NULL,
"text" text NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "comment_text_length" CHECK (length("guides"."comment_revision"."text") <= 4000)
);
--> statement-breakpoint
CREATE TABLE "guides"."comment_thread" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"guide_id" uuid,
"schedule_id" integer,
CONSTRAINT "comment_thread_one_target" CHECK (("guides"."comment_thread"."guide_id" is null) <> ("guides"."comment_thread"."schedule_id" is null))
);
--> statement-breakpoint
CREATE TABLE "guides"."comment" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"thread_id" uuid NOT NULL,
"author_id" text NOT NULL,
"root_id" uuid,
"reply_to_id" uuid,
"version" integer DEFAULT 1 NOT NULL,
"hidden" boolean DEFAULT false NOT NULL,
"deleted_at" timestamp with time zone,
"hearted_by_id" text,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "comment_reply_shape" CHECK (("guides"."comment"."root_id" is null) = ("guides"."comment"."reply_to_id" is null)),
CONSTRAINT "comment_version_positive" CHECK ("guides"."comment"."version" > 0)
);
--> statement-breakpoint
CREATE UNIQUE INDEX "comment_thread_id_unique" ON "guides"."comment" USING btree ("thread_id","id");--> statement-breakpoint
ALTER TABLE "guides"."comment_attachment" ADD CONSTRAINT "comment_attachment_comment_id_comment_id_fk" FOREIGN KEY ("comment_id") REFERENCES "guides"."comment"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "guides"."comment_reaction" ADD CONSTRAINT "comment_reaction_comment_id_comment_id_fk" FOREIGN KEY ("comment_id") REFERENCES "guides"."comment"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "guides"."comment_reaction" ADD CONSTRAINT "comment_reaction_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "auth"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "guides"."comment_revision_attachment" ADD CONSTRAINT "comment_revision_attachment_revision_id_comment_revision_id_fk" FOREIGN KEY ("revision_id") REFERENCES "guides"."comment_revision"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "guides"."comment_revision_attachment" ADD CONSTRAINT "comment_revision_attachment_attachment_id_comment_attachment_id_fk" FOREIGN KEY ("attachment_id") REFERENCES "guides"."comment_attachment"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "guides"."comment_revision" ADD CONSTRAINT "comment_revision_comment_id_comment_id_fk" FOREIGN KEY ("comment_id") REFERENCES "guides"."comment"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "guides"."comment_thread" ADD CONSTRAINT "comment_thread_guide_id_guide_id_fk" FOREIGN KEY ("guide_id") REFERENCES "guides"."guide"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "guides"."comment_thread" ADD CONSTRAINT "comment_thread_schedule_id_stygian_schedule_schedule_id_fk" FOREIGN KEY ("schedule_id") REFERENCES "guides"."stygian_schedule"("schedule_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "guides"."comment" ADD CONSTRAINT "comment_thread_id_comment_thread_id_fk" FOREIGN KEY ("thread_id") REFERENCES "guides"."comment_thread"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "guides"."comment" ADD CONSTRAINT "comment_author_id_user_id_fk" FOREIGN KEY ("author_id") REFERENCES "auth"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "guides"."comment" ADD CONSTRAINT "comment_hearted_by_id_user_id_fk" FOREIGN KEY ("hearted_by_id") REFERENCES "auth"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "guides"."comment" ADD CONSTRAINT "comment_thread_id_root_id_comment_thread_id_id_fk" FOREIGN KEY ("thread_id","root_id") REFERENCES "guides"."comment"("thread_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "guides"."comment" ADD CONSTRAINT "comment_thread_id_reply_to_id_comment_thread_id_id_fk" FOREIGN KEY ("thread_id","reply_to_id") REFERENCES "guides"."comment"("thread_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
CREATE UNIQUE INDEX "comment_attachment_key_unique" ON "guides"."comment_attachment" USING btree ("object_key");--> statement-breakpoint
CREATE INDEX "comment_attachment_comment_idx" ON "guides"."comment_attachment" USING btree ("comment_id");--> statement-breakpoint
CREATE UNIQUE INDEX "comment_revision_attachment_position_unique" ON "guides"."comment_revision_attachment" USING btree ("revision_id","position");--> statement-breakpoint
CREATE UNIQUE INDEX "comment_revision_version_unique" ON "guides"."comment_revision" USING btree ("comment_id","version");--> statement-breakpoint
CREATE UNIQUE INDEX "comment_thread_guide_unique" ON "guides"."comment_thread" USING btree ("guide_id");--> statement-breakpoint
CREATE UNIQUE INDEX "comment_thread_schedule_unique" ON "guides"."comment_thread" USING btree ("schedule_id");--> statement-breakpoint
CREATE INDEX "comment_thread_root_time_idx" ON "guides"."comment" USING btree ("thread_id","root_id","created_at","id");--> statement-breakpoint
CREATE INDEX "comment_root_time_idx" ON "guides"."comment" USING btree ("root_id","created_at","id");--> statement-breakpoint
CREATE INDEX "comment_inbox_time_idx" ON "guides"."comment" USING btree ("created_at","id");
+13
View File
@@ -0,0 +1,13 @@
CREATE SCHEMA "comments";
--> statement-breakpoint
ALTER TABLE "guides"."comment_attachment" SET SCHEMA "comments";
--> statement-breakpoint
ALTER TABLE "guides"."comment_reaction" SET SCHEMA "comments";
--> statement-breakpoint
ALTER TABLE "guides"."comment_revision_attachment" SET SCHEMA "comments";
--> statement-breakpoint
ALTER TABLE "guides"."comment_revision" SET SCHEMA "comments";
--> statement-breakpoint
ALTER TABLE "guides"."comment_thread" SET SCHEMA "comments";
--> statement-breakpoint
ALTER TABLE "guides"."comment" SET SCHEMA "comments";
+17
View File
@@ -0,0 +1,17 @@
-- Rename tables and their generated constraints in place, preserving data and indexes.
ALTER TABLE "comments"."comment_attachment" RENAME TO "attachment";--> statement-breakpoint
ALTER TABLE "comments"."comment_reaction" RENAME TO "reaction";--> statement-breakpoint
ALTER TABLE "comments"."comment_revision_attachment" RENAME TO "revision_attachment";--> statement-breakpoint
ALTER TABLE "comments"."comment_revision" RENAME TO "revision";--> statement-breakpoint
ALTER TABLE "comments"."comment_thread" RENAME TO "thread";--> statement-breakpoint
ALTER TABLE "comments"."attachment" RENAME CONSTRAINT "comment_attachment_comment_id_comment_id_fk" TO "attachment_comment_id_comment_id_fk";--> statement-breakpoint
ALTER TABLE "comments"."reaction" RENAME CONSTRAINT "comment_reaction_comment_id_comment_id_fk" TO "reaction_comment_id_comment_id_fk";--> statement-breakpoint
ALTER TABLE "comments"."reaction" RENAME CONSTRAINT "comment_reaction_user_id_user_id_fk" TO "reaction_user_id_user_id_fk";--> statement-breakpoint
ALTER TABLE "comments"."revision_attachment" RENAME CONSTRAINT "comment_revision_attachment_revision_id_comment_revision_id_fk" TO "revision_attachment_revision_id_revision_id_fk";--> statement-breakpoint
ALTER TABLE "comments"."revision_attachment" RENAME CONSTRAINT "comment_revision_attachment_attachment_id_comment_attachment_id_fk" TO "revision_attachment_attachment_id_attachment_id_fk";--> statement-breakpoint
ALTER TABLE "comments"."revision" RENAME CONSTRAINT "comment_revision_comment_id_comment_id_fk" TO "revision_comment_id_comment_id_fk";--> statement-breakpoint
ALTER TABLE "comments"."thread" RENAME CONSTRAINT "comment_thread_guide_id_guide_id_fk" TO "thread_guide_id_guide_id_fk";--> statement-breakpoint
ALTER TABLE "comments"."thread" RENAME CONSTRAINT "comment_thread_schedule_id_stygian_schedule_schedule_id_fk" TO "thread_schedule_id_stygian_schedule_schedule_id_fk";--> statement-breakpoint
ALTER TABLE "comments"."comment" RENAME CONSTRAINT "comment_thread_id_comment_thread_id_fk" TO "comment_thread_id_thread_id_fk";--> statement-breakpoint
ALTER TABLE "comments"."reaction" RENAME CONSTRAINT "comment_reaction_comment_id_user_id_pk" TO "reaction_comment_id_user_id_pk";--> statement-breakpoint
ALTER TABLE "comments"."revision_attachment" RENAME CONSTRAINT "comment_revision_attachment_revision_id_attachment_id_pk" TO "revision_attachment_revision_id_attachment_id_pk";
+10
View File
@@ -0,0 +1,10 @@
CREATE TABLE "comments"."push_subscription" (
"endpoint" text PRIMARY KEY NOT NULL,
"user_id" text NOT NULL,
"p256dh" text NOT NULL,
"auth" text NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "comments"."push_subscription" ADD CONSTRAINT "push_subscription_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "auth"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "comment_push_subscription_user_idx" ON "comments"."push_subscription" USING btree ("user_id");
+8
View File
@@ -0,0 +1,8 @@
CREATE TABLE "comments"."read_state" (
"user_id" text NOT NULL,
"target" text NOT NULL,
"seen_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "read_state_user_id_target_pk" PRIMARY KEY("user_id","target")
);
--> statement-breakpoint
ALTER TABLE "comments"."read_state" ADD CONSTRAINT "read_state_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "auth"."user"("id") ON DELETE cascade ON UPDATE no action;
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+35
View File
@@ -512,6 +512,41 @@
"when": 1791206244855,
"tag": "0072_sweet_joseph",
"breakpoints": true
},
{
"idx": 73,
"version": "7",
"when": 1791385900951,
"tag": "0073_unusual_darkhawk",
"breakpoints": true
},
{
"idx": 74,
"version": "7",
"when": 1791388055693,
"tag": "0074_tough_cerise",
"breakpoints": true
},
{
"idx": 75,
"version": "7",
"when": 1791388353500,
"tag": "0075_fancy_ravenous",
"breakpoints": true
},
{
"idx": 76,
"version": "7",
"when": 1791394746717,
"tag": "0076_free_jazinda",
"breakpoints": true
},
{
"idx": 77,
"version": "7",
"when": 1791395148797,
"tag": "0077_reflective_chimera",
"breakpoints": true
}
]
}