Merge branch 'master' into feature/cases

This commit is contained in:
2026-07-10 15:26:36 +03:30
68 changed files with 2497 additions and 604 deletions

View File

@@ -0,0 +1,25 @@
-- AlterTable
ALTER TABLE "users" ADD COLUMN "mobile" TEXT;
-- CreateIndex
CREATE UNIQUE INDEX "users_mobile_key" ON "users"("mobile");
-- CreateTable
CREATE TABLE "phone_verification_codes" (
"id" TEXT NOT NULL,
"userId" TEXT,
"mobile" TEXT NOT NULL,
"codeHash" TEXT NOT NULL,
"purpose" TEXT NOT NULL,
"expiresAt" TIMESTAMP(3) NOT NULL,
"verifiedAt" TIMESTAMP(3),
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "phone_verification_codes_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "phone_verification_codes_mobile_purpose_createdAt_idx" ON "phone_verification_codes"("mobile", "purpose", "createdAt");
-- AddForeignKey
ALTER TABLE "phone_verification_codes" ADD CONSTRAINT "phone_verification_codes_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@@ -0,0 +1,11 @@
-- Enforce one treatment detail per lab case (1:1 via join table).
-- Keep the earliest-linked detail when duplicate rows exist for the same case.
DELETE FROM "lab_case_details" lcd
WHERE lcd.ctid NOT IN (
SELECT MIN(inner_lcd.ctid)
FROM "lab_case_details" inner_lcd
GROUP BY inner_lcd."labCaseId"
);
CREATE UNIQUE INDEX "lab_case_details_labCaseId_key" ON "lab_case_details"("labCaseId");