feat: add migration

This commit is contained in:
Sergey Krylov 2026-03-18 06:08:28 +03:00
parent 6a60d5f8c0
commit 4e52b1a372
3 changed files with 50 additions and 1 deletions

View File

@ -0,0 +1,46 @@
-- CreateEnum
CREATE TYPE "roles" AS ENUM ('ADMIN', 'USER');
-- CreateTable
CREATE TABLE "accounts" (
"id" TEXT NOT NULL,
"phone" TEXT,
"email" TEXT,
"is_phone_verified" BOOLEAN NOT NULL DEFAULT false,
"is_email_verified" BOOLEAN NOT NULL DEFAULT false,
"role" "roles" NOT NULL DEFAULT 'USER',
"telegram_id" TEXT,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
CONSTRAINT "accounts_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "pending_contact_changes" (
"id" TEXT NOT NULL,
"type" TEXT NOT NULL,
"value" TEXT NOT NULL,
"code_hash" TEXT NOT NULL,
"expires_at" TIMESTAMP(3) NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
"account_id" TEXT NOT NULL,
CONSTRAINT "pending_contact_changes_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "accounts_phone_key" ON "accounts"("phone");
-- CreateIndex
CREATE UNIQUE INDEX "accounts_email_key" ON "accounts"("email");
-- CreateIndex
CREATE UNIQUE INDEX "accounts_telegram_id_key" ON "accounts"("telegram_id");
-- CreateIndex
CREATE UNIQUE INDEX "pending_contact_changes_account_id_type_key" ON "pending_contact_changes"("account_id", "type");
-- AddForeignKey
ALTER TABLE "pending_contact_changes" ADD CONSTRAINT "pending_contact_changes_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "accounts"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (e.g., Git)
provider = "postgresql"

View File

@ -1,4 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
"exclude": ["node_modules", "test", "dist", "prisma", "**/*spec.ts"]
}