fix: 限制有效签名名称唯一并保留批量导入补资料
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
BEGIN;
|
||||
|
||||
-- Preserve every historical record. A conflicting installation must be reviewed before release.
|
||||
LOCK TABLE "SmsSignature" IN SHARE ROW EXCLUSIVE MODE;
|
||||
DO $$
|
||||
BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM "SmsSignature"
|
||||
WHERE "auditStatus" NOT IN ('deleted', 'disabled')
|
||||
GROUP BY "tenantId", "applicationId", "name" HAVING count(*) > 1
|
||||
) THEN
|
||||
RAISE EXCEPTION 'Cannot enforce signature uniqueness: duplicate active signatures exist; review tenantId/applicationId/name groups without deleting or merging automatically';
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
CREATE UNIQUE INDEX "SmsSignature_active_application_name_key"
|
||||
ON "SmsSignature" ("tenantId", "applicationId", "name")
|
||||
WHERE "applicationId" IS NOT NULL AND "auditStatus" NOT IN ('deleted', 'disabled');
|
||||
|
||||
CREATE UNIQUE INDEX "SmsSignature_active_unbound_name_key"
|
||||
ON "SmsSignature" ("tenantId", "name")
|
||||
WHERE "applicationId" IS NULL AND "auditStatus" NOT IN ('deleted', 'disabled');
|
||||
|
||||
COMMIT;
|
||||
@@ -776,6 +776,8 @@ model ReportNotificationRead {
|
||||
}
|
||||
|
||||
model SmsSignature {
|
||||
// Active name uniqueness (including null applicationId) is enforced by two partial SQL indexes.
|
||||
// Owned by migration 20260917120000_signature_active_name_unique; do not replace with @@unique.
|
||||
id String @id @default(cuid())
|
||||
tenantId String
|
||||
applicationId String?
|
||||
|
||||
Reference in New Issue
Block a user