优化路径,添加消息推送
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[publicId]` on the table `FamilyMessage` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "FamilyMessage" ADD COLUMN "publicId" SERIAL NOT NULL;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "PushSubscription" (
|
||||
"id" TEXT NOT NULL,
|
||||
"caregiverId" TEXT NOT NULL,
|
||||
"endpoint" TEXT NOT NULL,
|
||||
"p256dh" TEXT NOT NULL,
|
||||
"auth" TEXT NOT NULL,
|
||||
"expirationTime" TIMESTAMP(3),
|
||||
"userAgent" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "PushSubscription_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "PushSubscription_endpoint_key" ON "PushSubscription"("endpoint");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "PushSubscription_caregiverId_updatedAt_idx" ON "PushSubscription"("caregiverId", "updatedAt" DESC);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "FamilyMessage_publicId_key" ON "FamilyMessage"("publicId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PushSubscription" ADD CONSTRAINT "PushSubscription_caregiverId_fkey" FOREIGN KEY ("caregiverId") REFERENCES "CaregiverAccount"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -53,6 +53,7 @@ model CaregiverAccount {
|
||||
updatedAt DateTime @updatedAt
|
||||
bindings DeviceBinding[]
|
||||
messages FamilyMessage[]
|
||||
pushSubscriptions PushSubscription[]
|
||||
}
|
||||
|
||||
model ElderDevice {
|
||||
@@ -84,6 +85,7 @@ model DeviceBinding {
|
||||
|
||||
model FamilyMessage {
|
||||
id String @id @default(cuid())
|
||||
publicId Int @unique @default(autoincrement())
|
||||
elderDeviceId String
|
||||
caregiverId String?
|
||||
direction MessageDirection
|
||||
@@ -102,6 +104,21 @@ model FamilyMessage {
|
||||
@@index([direction, status, createdAt(sort: Desc)])
|
||||
}
|
||||
|
||||
model PushSubscription {
|
||||
id String @id @default(cuid())
|
||||
caregiverId String
|
||||
endpoint String @unique
|
||||
p256dh String
|
||||
auth String
|
||||
expirationTime DateTime?
|
||||
userAgent String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
caregiver CaregiverAccount @relation(fields: [caregiverId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([caregiverId, updatedAt(sort: Desc)])
|
||||
}
|
||||
|
||||
model ConversationTurn {
|
||||
id String @id @default(cuid())
|
||||
elderDeviceId String
|
||||
|
||||
Reference in New Issue
Block a user