fix: harden real backend workflows and channel connections

This commit is contained in:
hectorzhao
2026-07-06 17:54:53 +08:00
parent 8cca361441
commit b5132d7f4e
47 changed files with 2530 additions and 314 deletions
@@ -0,0 +1,11 @@
-- Make CMPP connection states application-scoped for enterprise application status.
ALTER TABLE "CmppConnectionState" ADD COLUMN "applicationId" TEXT;
ALTER TABLE "CmppConnectionState" ADD CONSTRAINT "CmppConnectionState_applicationId_fkey"
FOREIGN KEY ("applicationId") REFERENCES "SmsApplication"("id") ON DELETE SET NULL ON UPDATE CASCADE;
DROP INDEX IF EXISTS "CmppConnectionState_channelId_connectionId_key";
CREATE UNIQUE INDEX "CmppConnectionState_applicationId_channelId_connectionId_key"
ON "CmppConnectionState"("applicationId", "channelId", "connectionId");
CREATE INDEX "CmppConnectionState_applicationId_status_idx"
ON "CmppConnectionState"("applicationId", "status");
+7 -3
View File
@@ -352,6 +352,7 @@ model SmsApplication {
sendTasks SmsSendTask[]
batchTasks SmsBatchTask[]
messageRecords SmsMessageRecord[]
connectionStates CmppConnectionState[]
@@index([tenantId, status])
}
@@ -502,6 +503,7 @@ model SmsChannel {
model CmppConnectionState {
id String @id @default(cuid())
tenantId String?
applicationId String?
channelId String
connectionId String
status String @default("disconnected")
@@ -515,11 +517,13 @@ model CmppConnectionState {
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
tenant Tenant? @relation(fields: [tenantId], references: [id])
channel SmsChannel @relation(fields: [channelId], references: [id])
tenant Tenant? @relation(fields: [tenantId], references: [id])
application SmsApplication? @relation(fields: [applicationId], references: [id])
channel SmsChannel @relation(fields: [channelId], references: [id])
@@unique([channelId, connectionId])
@@unique([applicationId, channelId, connectionId])
@@index([tenantId, status])
@@index([applicationId, status])
@@index([channelId, status])
}