@varaos/db 1.1.12 → 1.1.13
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,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- You are about to drop the column `userId` on the `PostReaction` table. All the data in the column will be lost.
|
|
5
|
+
- You are about to drop the column `userId` on the `PostShare` table. All the data in the column will be lost.
|
|
6
|
+
- A unique constraint covering the columns `[postId,visitorId,type]` on the table `PostReaction` will be added. If there are existing duplicate values, this will fail.
|
|
7
|
+
|
|
8
|
+
*/
|
|
9
|
+
-- DropForeignKey
|
|
10
|
+
ALTER TABLE "public"."PostReaction" DROP CONSTRAINT "PostReaction_userId_fkey";
|
|
11
|
+
|
|
12
|
+
-- DropForeignKey
|
|
13
|
+
ALTER TABLE "public"."PostShare" DROP CONSTRAINT "PostShare_userId_fkey";
|
|
14
|
+
|
|
15
|
+
-- DropIndex
|
|
16
|
+
DROP INDEX "public"."PostReaction_postId_userId_type_key";
|
|
17
|
+
|
|
18
|
+
-- DropIndex
|
|
19
|
+
DROP INDEX "public"."PostReaction_userId_idx";
|
|
20
|
+
|
|
21
|
+
-- DropIndex
|
|
22
|
+
DROP INDEX "public"."PostShare_userId_idx";
|
|
23
|
+
|
|
24
|
+
-- AlterTable
|
|
25
|
+
ALTER TABLE "public"."PostReaction" DROP COLUMN "userId",
|
|
26
|
+
ADD COLUMN "visitorId" TEXT;
|
|
27
|
+
|
|
28
|
+
-- AlterTable
|
|
29
|
+
ALTER TABLE "public"."PostShare" DROP COLUMN "userId",
|
|
30
|
+
ADD COLUMN "visitorId" TEXT;
|
|
31
|
+
|
|
32
|
+
-- CreateIndex
|
|
33
|
+
CREATE INDEX "PostReaction_visitorId_idx" ON "public"."PostReaction"("visitorId");
|
|
34
|
+
|
|
35
|
+
-- CreateIndex
|
|
36
|
+
CREATE UNIQUE INDEX "PostReaction_postId_visitorId_type_key" ON "public"."PostReaction"("postId", "visitorId", "type");
|
|
37
|
+
|
|
38
|
+
-- CreateIndex
|
|
39
|
+
CREATE INDEX "PostShare_visitorId_idx" ON "public"."PostShare"("visitorId");
|
|
40
|
+
|
|
41
|
+
-- AddForeignKey
|
|
42
|
+
ALTER TABLE "public"."PostReaction" ADD CONSTRAINT "PostReaction_visitorId_fkey" FOREIGN KEY ("visitorId") REFERENCES "public"."Visitor"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
43
|
+
|
|
44
|
+
-- AddForeignKey
|
|
45
|
+
ALTER TABLE "public"."PostShare" ADD CONSTRAINT "PostShare_visitorId_fkey" FOREIGN KEY ("visitorId") REFERENCES "public"."Visitor"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
package/prisma/schema.prisma
CHANGED
|
@@ -99,11 +99,9 @@ model User {
|
|
|
99
99
|
Onboarding Onboarding?
|
|
100
100
|
ChatSession ChatSession[]
|
|
101
101
|
|
|
102
|
-
createdAt
|
|
103
|
-
updatedAt
|
|
104
|
-
posts
|
|
105
|
-
postReactions PostReaction[]
|
|
106
|
-
postShares PostShare[]
|
|
102
|
+
createdAt DateTime @default(now())
|
|
103
|
+
updatedAt DateTime @updatedAt
|
|
104
|
+
posts Post[]
|
|
107
105
|
|
|
108
106
|
@@index([status])
|
|
109
107
|
}
|
|
@@ -598,8 +596,10 @@ model Visitor {
|
|
|
598
596
|
lastVisit DateTime @updatedAt
|
|
599
597
|
visitCount Int @default(1)
|
|
600
598
|
|
|
601
|
-
createdAt
|
|
602
|
-
updatedAt
|
|
599
|
+
createdAt DateTime @default(now())
|
|
600
|
+
updatedAt DateTime @updatedAt
|
|
601
|
+
postReactions PostReaction[]
|
|
602
|
+
postShares PostShare[]
|
|
603
603
|
|
|
604
604
|
@@index([createdAt])
|
|
605
605
|
}
|
|
@@ -745,7 +745,7 @@ model PostComment {
|
|
|
745
745
|
model PostReaction {
|
|
746
746
|
id String @id @default(uuid())
|
|
747
747
|
postId String
|
|
748
|
-
|
|
748
|
+
visitorId String? // Could be Visitor.visitorId
|
|
749
749
|
identityId String? // If commenter also reacts
|
|
750
750
|
type ReactionType
|
|
751
751
|
|
|
@@ -753,16 +753,16 @@ model PostReaction {
|
|
|
753
753
|
deletedAt DateTime?
|
|
754
754
|
|
|
755
755
|
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
|
|
756
|
-
|
|
756
|
+
visitor Visitor? @relation(fields: [visitorId], references: [id])
|
|
757
757
|
identity CommentIdentity? @relation(fields: [identityId], references: [id])
|
|
758
758
|
|
|
759
759
|
createdAt DateTime @default(now())
|
|
760
760
|
updatedAt DateTime @updatedAt
|
|
761
761
|
|
|
762
|
-
@@unique([postId,
|
|
762
|
+
@@unique([postId, visitorId, type])
|
|
763
763
|
@@unique([postId, identityId, type])
|
|
764
764
|
@@index([postId])
|
|
765
|
-
@@index([
|
|
765
|
+
@@index([visitorId])
|
|
766
766
|
@@index([identityId])
|
|
767
767
|
@@index([type])
|
|
768
768
|
}
|
|
@@ -774,19 +774,19 @@ model PostReaction {
|
|
|
774
774
|
model PostShare {
|
|
775
775
|
id String @id @default(uuid())
|
|
776
776
|
postId String
|
|
777
|
-
|
|
777
|
+
visitorId String?
|
|
778
778
|
identityId String?
|
|
779
779
|
platform String? // twitter | whatsapp | copy | linkedin | etc.
|
|
780
780
|
metadata Json?
|
|
781
781
|
|
|
782
782
|
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
|
|
783
|
-
|
|
783
|
+
visitor Visitor? @relation(fields: [visitorId], references: [id])
|
|
784
784
|
identity CommentIdentity? @relation(fields: [identityId], references: [id])
|
|
785
785
|
|
|
786
786
|
createdAt DateTime @default(now())
|
|
787
787
|
|
|
788
788
|
@@index([postId])
|
|
789
|
-
@@index([
|
|
789
|
+
@@index([visitorId])
|
|
790
790
|
@@index([identityId])
|
|
791
791
|
@@index([platform])
|
|
792
792
|
}
|