diff --git a/src/prisma/migrations/20241106102041_scout_telegram_user/migration.sql b/src/prisma/migrations/20241106102041_scout_telegram_user/migration.sql new file mode 100644 index 00000000..12bbf4f4 --- /dev/null +++ b/src/prisma/migrations/20241106102041_scout_telegram_user/migration.sql @@ -0,0 +1,23 @@ +-- CreateTable +CREATE TABLE "ScoutTelegramUser" ( + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "scoutId" UUID NOT NULL, + "telegramId" BIGINT NOT NULL, + "username" TEXT NOT NULL, + "avatar" TEXT, + + CONSTRAINT "ScoutTelegramUser_pkey" PRIMARY KEY ("telegramId") +); + +-- CreateIndex +CREATE UNIQUE INDEX "ScoutTelegramUser_scoutId_key" ON "ScoutTelegramUser"("scoutId"); + +-- CreateIndex +CREATE INDEX "ScoutTelegramUser_telegramId_idx" ON "ScoutTelegramUser"("telegramId"); + +-- CreateIndex +CREATE INDEX "ScoutTelegramUser_scoutId_idx" ON "ScoutTelegramUser"("scoutId"); + +-- AddForeignKey +ALTER TABLE "ScoutTelegramUser" ADD CONSTRAINT "ScoutTelegramUser_scoutId_fkey" FOREIGN KEY ("scoutId") REFERENCES "Scout"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/src/prisma/schema.prisma b/src/prisma/schema.prisma index 27a9fa71..03515263 100644 --- a/src/prisma/schema.prisma +++ b/src/prisma/schema.prisma @@ -2803,6 +2803,7 @@ model Scout { agreedToTermsAt DateTime? onboardedAt DateTime? currentBalance Int @default(0) + telegramUser ScoutTelegramUser? scoutWallet ScoutWallet[] strikes BuilderStrike[] events BuilderEvent[] @@ -3178,3 +3179,16 @@ model ScoutWallet { @@index([address]) @@index([scoutId]) } + +model ScoutTelegramUser { + createdAt DateTime @default(now()) + updatedAt DateTime @default(now()) + scoutId String @unique @db.Uuid + telegramId BigInt @id + username String + avatar String? + scout Scout @relation(fields: [scoutId], references: [id], onDelete: Cascade) + + @@index([telegramId]) + @@index([scoutId]) +}