From 4e52b1a372c8fdd102c3d17032ad2bb5cdf0f8ab Mon Sep 17 00:00:00 2001 From: Sergey Krylov Date: Wed, 18 Mar 2026 06:08:28 +0300 Subject: [PATCH] feat: add migration --- .../20260309051819_init/migration.sql | 46 +++++++++++++++++++ prisma/migrations/migration_lock.toml | 3 ++ tsconfig.build.json | 2 +- 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 prisma/migrations/20260309051819_init/migration.sql create mode 100644 prisma/migrations/migration_lock.toml diff --git a/prisma/migrations/20260309051819_init/migration.sql b/prisma/migrations/20260309051819_init/migration.sql new file mode 100644 index 0000000..48dc7f7 --- /dev/null +++ b/prisma/migrations/20260309051819_init/migration.sql @@ -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; diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml new file mode 100644 index 0000000..044d57c --- /dev/null +++ b/prisma/migrations/migration_lock.toml @@ -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" diff --git a/tsconfig.build.json b/tsconfig.build.json index 64f86c6..e97f053 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,4 +1,4 @@ { "extends": "./tsconfig.json", - "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] + "exclude": ["node_modules", "test", "dist", "prisma", "**/*spec.ts"] }