@varaos/db 1.1.10 → 1.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
-- CreateEnum
|
|
2
|
+
CREATE TYPE "public"."ReactionType" AS ENUM ('LIKE', 'LOVE', 'CLAP', 'FIRE', 'WOW');
|
|
3
|
+
|
|
4
|
+
-- CreateTable
|
|
5
|
+
CREATE TABLE "public"."CommentIdentity" (
|
|
6
|
+
"id" TEXT NOT NULL,
|
|
7
|
+
"name" TEXT NOT NULL,
|
|
8
|
+
"email" TEXT NOT NULL,
|
|
9
|
+
"verified" BOOLEAN NOT NULL DEFAULT false,
|
|
10
|
+
"metadata" JSONB,
|
|
11
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
12
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
13
|
+
|
|
14
|
+
CONSTRAINT "CommentIdentity_pkey" PRIMARY KEY ("id")
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
-- CreateTable
|
|
18
|
+
CREATE TABLE "public"."PostComment" (
|
|
19
|
+
"id" TEXT NOT NULL,
|
|
20
|
+
"postId" TEXT NOT NULL,
|
|
21
|
+
"identityId" TEXT,
|
|
22
|
+
"parentId" TEXT,
|
|
23
|
+
"content" TEXT NOT NULL,
|
|
24
|
+
"status" "public"."Status" NOT NULL DEFAULT 'active',
|
|
25
|
+
"deletedAt" TIMESTAMP(3),
|
|
26
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
27
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
28
|
+
|
|
29
|
+
CONSTRAINT "PostComment_pkey" PRIMARY KEY ("id")
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
-- CreateTable
|
|
33
|
+
CREATE TABLE "public"."PostReaction" (
|
|
34
|
+
"id" TEXT NOT NULL,
|
|
35
|
+
"postId" TEXT NOT NULL,
|
|
36
|
+
"userId" TEXT,
|
|
37
|
+
"identityId" TEXT,
|
|
38
|
+
"type" "public"."ReactionType" NOT NULL,
|
|
39
|
+
"status" "public"."Status" NOT NULL DEFAULT 'active',
|
|
40
|
+
"deletedAt" TIMESTAMP(3),
|
|
41
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
42
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
43
|
+
|
|
44
|
+
CONSTRAINT "PostReaction_pkey" PRIMARY KEY ("id")
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
-- CreateTable
|
|
48
|
+
CREATE TABLE "public"."PostShare" (
|
|
49
|
+
"id" TEXT NOT NULL,
|
|
50
|
+
"postId" TEXT NOT NULL,
|
|
51
|
+
"userId" TEXT,
|
|
52
|
+
"identityId" TEXT,
|
|
53
|
+
"platform" TEXT,
|
|
54
|
+
"metadata" JSONB,
|
|
55
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
56
|
+
|
|
57
|
+
CONSTRAINT "PostShare_pkey" PRIMARY KEY ("id")
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
-- CreateIndex
|
|
61
|
+
CREATE UNIQUE INDEX "CommentIdentity_email_key" ON "public"."CommentIdentity"("email");
|
|
62
|
+
|
|
63
|
+
-- CreateIndex
|
|
64
|
+
CREATE INDEX "CommentIdentity_email_idx" ON "public"."CommentIdentity"("email");
|
|
65
|
+
|
|
66
|
+
-- CreateIndex
|
|
67
|
+
CREATE INDEX "PostComment_postId_idx" ON "public"."PostComment"("postId");
|
|
68
|
+
|
|
69
|
+
-- CreateIndex
|
|
70
|
+
CREATE INDEX "PostComment_identityId_idx" ON "public"."PostComment"("identityId");
|
|
71
|
+
|
|
72
|
+
-- CreateIndex
|
|
73
|
+
CREATE INDEX "PostComment_parentId_idx" ON "public"."PostComment"("parentId");
|
|
74
|
+
|
|
75
|
+
-- CreateIndex
|
|
76
|
+
CREATE INDEX "PostComment_status_idx" ON "public"."PostComment"("status");
|
|
77
|
+
|
|
78
|
+
-- CreateIndex
|
|
79
|
+
CREATE INDEX "PostReaction_postId_idx" ON "public"."PostReaction"("postId");
|
|
80
|
+
|
|
81
|
+
-- CreateIndex
|
|
82
|
+
CREATE INDEX "PostReaction_userId_idx" ON "public"."PostReaction"("userId");
|
|
83
|
+
|
|
84
|
+
-- CreateIndex
|
|
85
|
+
CREATE INDEX "PostReaction_identityId_idx" ON "public"."PostReaction"("identityId");
|
|
86
|
+
|
|
87
|
+
-- CreateIndex
|
|
88
|
+
CREATE INDEX "PostReaction_type_idx" ON "public"."PostReaction"("type");
|
|
89
|
+
|
|
90
|
+
-- CreateIndex
|
|
91
|
+
CREATE UNIQUE INDEX "PostReaction_postId_userId_type_key" ON "public"."PostReaction"("postId", "userId", "type");
|
|
92
|
+
|
|
93
|
+
-- CreateIndex
|
|
94
|
+
CREATE UNIQUE INDEX "PostReaction_postId_identityId_type_key" ON "public"."PostReaction"("postId", "identityId", "type");
|
|
95
|
+
|
|
96
|
+
-- CreateIndex
|
|
97
|
+
CREATE INDEX "PostShare_postId_idx" ON "public"."PostShare"("postId");
|
|
98
|
+
|
|
99
|
+
-- CreateIndex
|
|
100
|
+
CREATE INDEX "PostShare_userId_idx" ON "public"."PostShare"("userId");
|
|
101
|
+
|
|
102
|
+
-- CreateIndex
|
|
103
|
+
CREATE INDEX "PostShare_identityId_idx" ON "public"."PostShare"("identityId");
|
|
104
|
+
|
|
105
|
+
-- CreateIndex
|
|
106
|
+
CREATE INDEX "PostShare_platform_idx" ON "public"."PostShare"("platform");
|
|
107
|
+
|
|
108
|
+
-- AddForeignKey
|
|
109
|
+
ALTER TABLE "public"."PostComment" ADD CONSTRAINT "PostComment_postId_fkey" FOREIGN KEY ("postId") REFERENCES "public"."Post"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
110
|
+
|
|
111
|
+
-- AddForeignKey
|
|
112
|
+
ALTER TABLE "public"."PostComment" ADD CONSTRAINT "PostComment_identityId_fkey" FOREIGN KEY ("identityId") REFERENCES "public"."CommentIdentity"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
113
|
+
|
|
114
|
+
-- AddForeignKey
|
|
115
|
+
ALTER TABLE "public"."PostComment" ADD CONSTRAINT "PostComment_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "public"."PostComment"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
116
|
+
|
|
117
|
+
-- AddForeignKey
|
|
118
|
+
ALTER TABLE "public"."PostReaction" ADD CONSTRAINT "PostReaction_postId_fkey" FOREIGN KEY ("postId") REFERENCES "public"."Post"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
119
|
+
|
|
120
|
+
-- AddForeignKey
|
|
121
|
+
ALTER TABLE "public"."PostReaction" ADD CONSTRAINT "PostReaction_userId_fkey" FOREIGN KEY ("userId") REFERENCES "public"."User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
122
|
+
|
|
123
|
+
-- AddForeignKey
|
|
124
|
+
ALTER TABLE "public"."PostReaction" ADD CONSTRAINT "PostReaction_identityId_fkey" FOREIGN KEY ("identityId") REFERENCES "public"."CommentIdentity"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
125
|
+
|
|
126
|
+
-- AddForeignKey
|
|
127
|
+
ALTER TABLE "public"."PostShare" ADD CONSTRAINT "PostShare_postId_fkey" FOREIGN KEY ("postId") REFERENCES "public"."Post"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
128
|
+
|
|
129
|
+
-- AddForeignKey
|
|
130
|
+
ALTER TABLE "public"."PostShare" ADD CONSTRAINT "PostShare_userId_fkey" FOREIGN KEY ("userId") REFERENCES "public"."User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
131
|
+
|
|
132
|
+
-- AddForeignKey
|
|
133
|
+
ALTER TABLE "public"."PostShare" ADD CONSTRAINT "PostShare_identityId_fkey" FOREIGN KEY ("identityId") REFERENCES "public"."CommentIdentity"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
package/prisma/schema.prisma
CHANGED
|
@@ -52,6 +52,14 @@ enum PostType {
|
|
|
52
52
|
SESSION
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
enum ReactionType {
|
|
56
|
+
LIKE
|
|
57
|
+
LOVE
|
|
58
|
+
CLAP
|
|
59
|
+
FIRE
|
|
60
|
+
WOW
|
|
61
|
+
}
|
|
62
|
+
|
|
55
63
|
/// ─────────────────────────────────────────────
|
|
56
64
|
/// USERS & AUTH
|
|
57
65
|
/// ─────────────────────────────────────────────
|
|
@@ -91,9 +99,11 @@ model User {
|
|
|
91
99
|
Onboarding Onboarding?
|
|
92
100
|
ChatSession ChatSession[]
|
|
93
101
|
|
|
94
|
-
createdAt
|
|
95
|
-
updatedAt
|
|
96
|
-
posts
|
|
102
|
+
createdAt DateTime @default(now())
|
|
103
|
+
updatedAt DateTime @updatedAt
|
|
104
|
+
posts Post[]
|
|
105
|
+
postReactions PostReaction[]
|
|
106
|
+
postShares PostShare[]
|
|
97
107
|
|
|
98
108
|
@@index([status])
|
|
99
109
|
}
|
|
@@ -628,27 +638,30 @@ model EmailSendLog {
|
|
|
628
638
|
}
|
|
629
639
|
|
|
630
640
|
model Post {
|
|
631
|
-
id
|
|
632
|
-
title
|
|
633
|
-
slug
|
|
634
|
-
excerpt
|
|
635
|
-
type
|
|
636
|
-
status
|
|
641
|
+
id String @id @default(uuid())
|
|
642
|
+
title String
|
|
643
|
+
slug String @unique
|
|
644
|
+
excerpt String?
|
|
645
|
+
type PostType @default(BLOG)
|
|
646
|
+
status Status @default(draft)
|
|
637
647
|
|
|
638
|
-
content
|
|
639
|
-
contentHtml
|
|
648
|
+
content Json
|
|
649
|
+
contentHtml String?
|
|
640
650
|
|
|
641
651
|
featuredImage String?
|
|
642
652
|
|
|
643
653
|
// many-to-many pivot
|
|
644
|
-
tags
|
|
654
|
+
tags PostTag[] @relation("PostTags")
|
|
645
655
|
|
|
646
|
-
authorId
|
|
647
|
-
author
|
|
656
|
+
authorId String?
|
|
657
|
+
author User? @relation(fields: [authorId], references: [id])
|
|
648
658
|
|
|
649
659
|
publishedAt DateTime?
|
|
650
|
-
createdAt DateTime
|
|
651
|
-
updatedAt DateTime
|
|
660
|
+
createdAt DateTime @default(now())
|
|
661
|
+
updatedAt DateTime @updatedAt
|
|
662
|
+
postComments PostComment[]
|
|
663
|
+
postReactions PostReaction[]
|
|
664
|
+
postShares PostShare[]
|
|
652
665
|
|
|
653
666
|
@@index([type])
|
|
654
667
|
@@index([status])
|
|
@@ -656,9 +669,9 @@ model Post {
|
|
|
656
669
|
}
|
|
657
670
|
|
|
658
671
|
model Tag {
|
|
659
|
-
id String
|
|
660
|
-
name String
|
|
661
|
-
|
|
672
|
+
id String @id @default(uuid())
|
|
673
|
+
name String @unique
|
|
674
|
+
color String @default("blue")
|
|
662
675
|
// inverse many-to-many pivot
|
|
663
676
|
posts PostTag[] @relation("PostTags")
|
|
664
677
|
}
|
|
@@ -673,4 +686,107 @@ model PostTag {
|
|
|
673
686
|
|
|
674
687
|
@@id([postId, tagId])
|
|
675
688
|
@@index([tagId])
|
|
676
|
-
}
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/// ─────────────────────────────────────────────
|
|
692
|
+
/// COMMENT IDENTITIES (Name + Email Login-less System)
|
|
693
|
+
/// ─────────────────────────────────────────────
|
|
694
|
+
|
|
695
|
+
model CommentIdentity {
|
|
696
|
+
id String @id @default(uuid())
|
|
697
|
+
name String
|
|
698
|
+
email String @unique
|
|
699
|
+
verified Boolean @default(false)
|
|
700
|
+
metadata Json?
|
|
701
|
+
|
|
702
|
+
createdAt DateTime @default(now())
|
|
703
|
+
updatedAt DateTime @updatedAt
|
|
704
|
+
|
|
705
|
+
comments PostComment[]
|
|
706
|
+
postReactions PostReaction[]
|
|
707
|
+
postShares PostShare[]
|
|
708
|
+
|
|
709
|
+
@@index([email])
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/// ─────────────────────────────────────────────
|
|
713
|
+
/// POST COMMENTS (Revised to use CommentIdentity)
|
|
714
|
+
/// ─────────────────────────────────────────────
|
|
715
|
+
|
|
716
|
+
model PostComment {
|
|
717
|
+
id String @id @default(uuid())
|
|
718
|
+
postId String
|
|
719
|
+
identityId String? // Instead of userId (for public commenters)
|
|
720
|
+
parentId String? // Threaded comments
|
|
721
|
+
|
|
722
|
+
content String
|
|
723
|
+
status Status @default(active)
|
|
724
|
+
deletedAt DateTime?
|
|
725
|
+
|
|
726
|
+
// Relations
|
|
727
|
+
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
|
|
728
|
+
identity CommentIdentity? @relation(fields: [identityId], references: [id])
|
|
729
|
+
parent PostComment? @relation("CommentReplies", fields: [parentId], references: [id])
|
|
730
|
+
replies PostComment[] @relation("CommentReplies")
|
|
731
|
+
|
|
732
|
+
createdAt DateTime @default(now())
|
|
733
|
+
updatedAt DateTime @updatedAt
|
|
734
|
+
|
|
735
|
+
@@index([postId])
|
|
736
|
+
@@index([identityId])
|
|
737
|
+
@@index([parentId])
|
|
738
|
+
@@index([status])
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
/// ─────────────────────────────────────────────
|
|
742
|
+
/// POST REACTIONS (LIKE, LOVE, CLAP, FIRE, WOW)
|
|
743
|
+
/// ─────────────────────────────────────────────
|
|
744
|
+
|
|
745
|
+
model PostReaction {
|
|
746
|
+
id String @id @default(uuid())
|
|
747
|
+
postId String
|
|
748
|
+
userId String? // Could be Visitor.visitorId
|
|
749
|
+
identityId String? // If commenter also reacts
|
|
750
|
+
type ReactionType
|
|
751
|
+
|
|
752
|
+
status Status @default(active)
|
|
753
|
+
deletedAt DateTime?
|
|
754
|
+
|
|
755
|
+
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
|
|
756
|
+
user User? @relation(fields: [userId], references: [id])
|
|
757
|
+
identity CommentIdentity? @relation(fields: [identityId], references: [id])
|
|
758
|
+
|
|
759
|
+
createdAt DateTime @default(now())
|
|
760
|
+
updatedAt DateTime @updatedAt
|
|
761
|
+
|
|
762
|
+
@@unique([postId, userId, type])
|
|
763
|
+
@@unique([postId, identityId, type])
|
|
764
|
+
@@index([postId])
|
|
765
|
+
@@index([userId])
|
|
766
|
+
@@index([identityId])
|
|
767
|
+
@@index([type])
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/// ─────────────────────────────────────────────
|
|
771
|
+
/// POST SHARES (Analytics + Share Platform Info)
|
|
772
|
+
/// ─────────────────────────────────────────────
|
|
773
|
+
|
|
774
|
+
model PostShare {
|
|
775
|
+
id String @id @default(uuid())
|
|
776
|
+
postId String
|
|
777
|
+
userId String?
|
|
778
|
+
identityId String?
|
|
779
|
+
platform String? // twitter | whatsapp | copy | linkedin | etc.
|
|
780
|
+
metadata Json?
|
|
781
|
+
|
|
782
|
+
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
|
|
783
|
+
user User? @relation(fields: [userId], references: [id])
|
|
784
|
+
identity CommentIdentity? @relation(fields: [identityId], references: [id])
|
|
785
|
+
|
|
786
|
+
createdAt DateTime @default(now())
|
|
787
|
+
|
|
788
|
+
@@index([postId])
|
|
789
|
+
@@index([userId])
|
|
790
|
+
@@index([identityId])
|
|
791
|
+
@@index([platform])
|
|
792
|
+
}
|