Skip to content

Commit 6ba0c31

Browse files
committed
Remove obsolete migration snapshot and update journal with new migration tag. Refactor ResourceReaction component for improved rendering and hover functionality. Enhance CommentSection and CommentItem components to handle mutation states more effectively. Create initial SQL migration for database schema including tables for articles, comments, reactions, and user management with appropriate foreign key constraints.
1 parent 0d6f12c commit 6ba0c31

11 files changed

+192
-3005
lines changed
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ CREATE TABLE "articles" (
1616
"is_published" boolean DEFAULT false,
1717
"published_at" timestamp,
1818
"approved_at" timestamp,
19+
"delete_scheduled_at" timestamp,
1920
"metadata" jsonb,
2021
"author_id" uuid NOT NULL,
2122
"created_at" timestamp,
@@ -34,14 +35,23 @@ CREATE TABLE "bookmarks" (
3435
CREATE TABLE "comments" (
3536
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
3637
"body" text NOT NULL,
37-
"commentable_type" varchar NOT NULL,
38-
"commentable_id" uuid NOT NULL,
38+
"resource_id" uuid NOT NULL,
39+
"resource_type" varchar(50) NOT NULL,
3940
"user_id" uuid NOT NULL,
40-
"parent_id" uuid,
4141
"created_at" timestamp DEFAULT now(),
4242
"updated_at" timestamp DEFAULT now()
4343
);
4444
--> statement-breakpoint
45+
CREATE TABLE "reactions" (
46+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
47+
"user_id" uuid NOT NULL,
48+
"resource_id" uuid NOT NULL,
49+
"resource_type" varchar(50) NOT NULL,
50+
"reaction_type" varchar(50) NOT NULL,
51+
"created_at" timestamp,
52+
"updated_at" timestamp
53+
);
54+
--> statement-breakpoint
4555
CREATE TABLE "series_items" (
4656
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
4757
"series_id" uuid NOT NULL,
@@ -124,7 +134,7 @@ ALTER TABLE "article_tag" ADD CONSTRAINT "article_tag_tag_id_tags_id_fk" FOREIGN
124134
ALTER TABLE "articles" ADD CONSTRAINT "articles_author_id_users_id_fk" FOREIGN KEY ("author_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
125135
ALTER TABLE "bookmarks" ADD CONSTRAINT "bookmarks_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
126136
ALTER TABLE "comments" ADD CONSTRAINT "comments_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
127-
ALTER TABLE "comments" ADD CONSTRAINT "comments_parent_id_comments_id_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."comments"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
137+
ALTER TABLE "reactions" ADD CONSTRAINT "reactions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
128138
ALTER TABLE "series_items" ADD CONSTRAINT "series_items_series_id_series_id_fk" FOREIGN KEY ("series_id") REFERENCES "public"."series"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
129139
ALTER TABLE "series_items" ADD CONSTRAINT "series_items_article_id_articles_id_fk" FOREIGN KEY ("article_id") REFERENCES "public"."articles"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
130140
ALTER TABLE "series" ADD CONSTRAINT "series_owner_id_users_id_fk" FOREIGN KEY ("owner_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint

migrations/0001_unknown_dark_beast.sql

Lines changed: 0 additions & 11 deletions
This file was deleted.

migrations/0002_unusual_mentallo.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.

migrations/0003_quiet_swarm.sql

Lines changed: 0 additions & 4 deletions
This file was deleted.

migrations/meta/0000_snapshot.json

Lines changed: 75 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id": "df7084a1-1c3d-4fa9-bc8a-aec9fbc6f26d",
2+
"id": "ac9572ba-b268-46e2-8276-3fccefb6a2fc",
33
"prevId": "00000000-0000-0000-0000-000000000000",
44
"version": "7",
55
"dialect": "postgresql",
@@ -135,6 +135,12 @@
135135
"primaryKey": false,
136136
"notNull": false
137137
},
138+
"delete_scheduled_at": {
139+
"name": "delete_scheduled_at",
140+
"type": "timestamp",
141+
"primaryKey": false,
142+
"notNull": false
143+
},
138144
"metadata": {
139145
"name": "metadata",
140146
"type": "jsonb",
@@ -263,15 +269,15 @@
263269
"primaryKey": false,
264270
"notNull": true
265271
},
266-
"commentable_type": {
267-
"name": "commentable_type",
268-
"type": "varchar",
272+
"resource_id": {
273+
"name": "resource_id",
274+
"type": "uuid",
269275
"primaryKey": false,
270276
"notNull": true
271277
},
272-
"commentable_id": {
273-
"name": "commentable_id",
274-
"type": "uuid",
278+
"resource_type": {
279+
"name": "resource_type",
280+
"type": "varchar(50)",
275281
"primaryKey": false,
276282
"notNull": true
277283
},
@@ -281,12 +287,6 @@
281287
"primaryKey": false,
282288
"notNull": true
283289
},
284-
"parent_id": {
285-
"name": "parent_id",
286-
"type": "uuid",
287-
"primaryKey": false,
288-
"notNull": false
289-
},
290290
"created_at": {
291291
"name": "created_at",
292292
"type": "timestamp",
@@ -316,13 +316,70 @@
316316
],
317317
"onDelete": "cascade",
318318
"onUpdate": "no action"
319+
}
320+
},
321+
"compositePrimaryKeys": {},
322+
"uniqueConstraints": {},
323+
"policies": {},
324+
"checkConstraints": {},
325+
"isRLSEnabled": false
326+
},
327+
"public.reactions": {
328+
"name": "reactions",
329+
"schema": "",
330+
"columns": {
331+
"id": {
332+
"name": "id",
333+
"type": "uuid",
334+
"primaryKey": true,
335+
"notNull": true,
336+
"default": "gen_random_uuid()"
319337
},
320-
"comments_parent_id_comments_id_fk": {
321-
"name": "comments_parent_id_comments_id_fk",
322-
"tableFrom": "comments",
323-
"tableTo": "comments",
338+
"user_id": {
339+
"name": "user_id",
340+
"type": "uuid",
341+
"primaryKey": false,
342+
"notNull": true
343+
},
344+
"resource_id": {
345+
"name": "resource_id",
346+
"type": "uuid",
347+
"primaryKey": false,
348+
"notNull": true
349+
},
350+
"resource_type": {
351+
"name": "resource_type",
352+
"type": "varchar(50)",
353+
"primaryKey": false,
354+
"notNull": true
355+
},
356+
"reaction_type": {
357+
"name": "reaction_type",
358+
"type": "varchar(50)",
359+
"primaryKey": false,
360+
"notNull": true
361+
},
362+
"created_at": {
363+
"name": "created_at",
364+
"type": "timestamp",
365+
"primaryKey": false,
366+
"notNull": false
367+
},
368+
"updated_at": {
369+
"name": "updated_at",
370+
"type": "timestamp",
371+
"primaryKey": false,
372+
"notNull": false
373+
}
374+
},
375+
"indexes": {},
376+
"foreignKeys": {
377+
"reactions_user_id_users_id_fk": {
378+
"name": "reactions_user_id_users_id_fk",
379+
"tableFrom": "reactions",
380+
"tableTo": "users",
324381
"columnsFrom": [
325-
"parent_id"
382+
"user_id"
326383
],
327384
"columnsTo": [
328385
"id"

0 commit comments

Comments
 (0)