Implement nation betting lifecycle

This commit is contained in:
2026-07-25 20:16:11 +00:00
parent 06ab6c3565
commit 25e67e15ae
15 changed files with 1750 additions and 0 deletions
+40
View File
@@ -489,6 +489,46 @@ model InheritancePoint {
@@map("inheritance_point")
}
model NationBetting {
id Int @id
type String @default("bettingNation")
name String
finished Boolean @default(false)
selectCount Int @map("select_count")
isExclusive Boolean? @map("is_exclusive")
requiresInheritancePoint Boolean @default(true) @map("requires_inheritance_point")
openYearMonth Int @map("open_year_month")
closeYearMonth Int @map("close_year_month")
candidates Json
winner Json?
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
bets NationBet[]
@@index([type, id])
@@map("nation_betting")
}
model NationBet {
id Int @id @default(autoincrement())
bettingId Int @map("betting_id")
generalId Int @map("general_id")
userId String? @map("user_id")
selection Json
selectionKey String @map("selection_key")
amount Float
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
betting NationBetting @relation(fields: [bettingId], references: [id], onDelete: Cascade)
@@unique([bettingId, userId, selectionKey])
@@index([bettingId])
@@index([bettingId, userId])
@@map("nation_bet")
}
model InheritanceLog {
id Int @id @default(autoincrement())
userId String @map("user_id")
@@ -0,0 +1,42 @@
CREATE TABLE "nation_betting" (
"id" INTEGER NOT NULL,
"type" TEXT NOT NULL DEFAULT 'bettingNation',
"name" TEXT NOT NULL,
"finished" BOOLEAN NOT NULL DEFAULT false,
"select_count" INTEGER NOT NULL,
"is_exclusive" BOOLEAN,
"requires_inheritance_point" BOOLEAN NOT NULL DEFAULT true,
"open_year_month" INTEGER NOT NULL,
"close_year_month" INTEGER NOT NULL,
"candidates" JSONB NOT NULL,
"winner" JSONB,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
CONSTRAINT "nation_betting_pkey" PRIMARY KEY ("id")
);
CREATE TABLE "nation_bet" (
"id" SERIAL NOT NULL,
"betting_id" INTEGER NOT NULL,
"general_id" INTEGER NOT NULL,
"user_id" TEXT,
"selection" JSONB NOT NULL,
"selection_key" TEXT NOT NULL,
"amount" DOUBLE PRECISION NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
CONSTRAINT "nation_bet_pkey" PRIMARY KEY ("id")
);
CREATE INDEX "nation_betting_type_id_idx" ON "nation_betting"("type", "id");
CREATE INDEX "nation_bet_betting_id_idx" ON "nation_bet"("betting_id");
CREATE INDEX "nation_bet_betting_id_user_id_idx" ON "nation_bet"("betting_id", "user_id");
CREATE UNIQUE INDEX "nation_bet_betting_id_user_id_selection_key_key"
ON "nation_bet"("betting_id", "user_id", "selection_key");
ALTER TABLE "nation_bet"
ADD CONSTRAINT "nation_bet_betting_id_fkey"
FOREIGN KEY ("betting_id") REFERENCES "nation_betting"("id")
ON DELETE CASCADE ON UPDATE CASCADE;
+2
View File
@@ -27,6 +27,8 @@ export interface DatabaseClient {
auction: GamePrisma.AuctionDelegate;
auctionBid: GamePrisma.AuctionBidDelegate;
inheritancePoint: GamePrisma.InheritancePointDelegate;
nationBetting: GamePrisma.NationBettingDelegate;
nationBet: GamePrisma.NationBetDelegate;
inheritanceLog: GamePrisma.InheritanceLogDelegate;
inheritanceResult: GamePrisma.InheritanceResultDelegate;
inheritanceUserState: GamePrisma.InheritanceUserStateDelegate;