feat: strengthen risk controls and review workflows
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
-- Risk thresholds now inherit from global rules and may be overridden per application.
|
||||
-- Existing maxPhonesPerTask values are intentionally discarded because this environment
|
||||
-- contains test-only application data and the product owner explicitly declined migration.
|
||||
ALTER TABLE "RiskRule" ADD COLUMN "applicationId" TEXT;
|
||||
|
||||
-- Retain historical rules and hit records for audit, but remove them from the
|
||||
-- effective rule set and configuration page.
|
||||
UPDATE "RiskRule"
|
||||
SET "status" = 'deleted'
|
||||
WHERE "code" IN (
|
||||
'DUPLICATE_PHONE_RATIO',
|
||||
'ILLEGAL_PHONE_RATIO',
|
||||
'BLACKLIST_HIT_RATIO',
|
||||
'TEMPLATE_VARIABLE_ANOMALY'
|
||||
);
|
||||
|
||||
UPDATE "RiskRule"
|
||||
SET "status" = 'deleted'
|
||||
WHERE "tenantId" IS NOT NULL AND "applicationId" IS NULL;
|
||||
|
||||
DROP INDEX IF EXISTS "RiskRule_tenantId_code_key";
|
||||
DROP INDEX IF EXISTS "RiskRule_tenantId_status_priority_idx";
|
||||
|
||||
CREATE UNIQUE INDEX "RiskRule_applicationId_code_key"
|
||||
ON "RiskRule"("applicationId", "code");
|
||||
|
||||
CREATE UNIQUE INDEX "RiskRule_global_code_key"
|
||||
ON "RiskRule"("code")
|
||||
WHERE "applicationId" IS NULL AND "status" <> 'deleted';
|
||||
|
||||
CREATE INDEX "RiskRule_tenantId_applicationId_status_priority_idx"
|
||||
ON "RiskRule"("tenantId", "applicationId", "status", "priority");
|
||||
|
||||
ALTER TABLE "RiskRule"
|
||||
ADD CONSTRAINT "RiskRule_applicationId_fkey"
|
||||
FOREIGN KEY ("applicationId") REFERENCES "SmsApplication"("id")
|
||||
ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE "SmsApplication" DROP COLUMN "maxPhonesPerTask";
|
||||
Reference in New Issue
Block a user