/*
  Warnings:

  - You are about to drop the column `closesAt` on the `Round` table. All the data in the column will be lost.
  - You are about to drop the column `seed` on the `Round` table. All the data in the column will be lost.
  - You are about to drop the column `seedHash` on the `Round` table. All the data in the column will be lost.
  - The values [SETTLED] on the enum `Round_status` will be removed. If these variants are still used in the database, this will fail.
  - A unique constraint covering the columns `[telegramId]` on the table `User` will be added. If there are existing duplicate values, this will fail.
  - Added the required column `odds` to the `Prediction` table without a default value. This is not possible if the table is not empty.
  - Added the required column `liveStreamTime` to the `Round` table without a default value. This is not possible if the table is not empty.
  - Added the required column `predictionDeadline` to the `Round` table without a default value. This is not possible if the table is not empty.

*/
-- AlterTable
ALTER TABLE `Prediction` ADD COLUMN `odds` DECIMAL(10, 2) NOT NULL;

-- AlterTable
ALTER TABLE `Round` DROP COLUMN `closesAt`,
    DROP COLUMN `seed`,
    DROP COLUMN `seedHash`,
    ADD COLUMN `dice1` INTEGER NULL,
    ADD COLUMN `dice2` INTEGER NULL,
    ADD COLUMN `liveStreamTime` DATETIME(3) NOT NULL,
    ADD COLUMN `predictionDeadline` DATETIME(3) NOT NULL,
    MODIFY `status` ENUM('OPEN', 'LOCKED', 'LIVE', 'CLOSED', 'CANCELLED') NOT NULL DEFAULT 'OPEN';

-- AlterTable
ALTER TABLE `Transaction` MODIFY `type` ENUM('DEPOSIT', 'WITHDRAWAL', 'PREDICTION', 'PAYOUT', 'ADJUSTMENT', 'REFERRAL_BONUS', 'REFUND') NOT NULL,
    MODIFY `status` ENUM('PENDING', 'SUCCESS', 'FAILED', 'CANCELLED') NOT NULL DEFAULT 'PENDING';

-- AlterTable
ALTER TABLE `User` ADD COLUMN `telegramId` VARCHAR(191) NULL,
    MODIFY `email` VARCHAR(191) NULL;

-- AlterTable
ALTER TABLE `Withdrawal` MODIFY `status` ENUM('PENDING', 'APPROVED', 'REJECTED', 'PAID', 'CANCELLED') NOT NULL DEFAULT 'PENDING';

-- CreateTable
CREATE TABLE `RoundOdds` (
    `id` VARCHAR(191) NOT NULL,
    `roundId` VARCHAR(191) NOT NULL,
    `number` INTEGER NOT NULL,
    `value` DECIMAL(10, 2) NOT NULL,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,

    INDEX `RoundOdds_roundId_idx`(`roundId`),
    UNIQUE INDEX `RoundOdds_roundId_number_key`(`roundId`, `number`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `SystemConfig` (
    `id` VARCHAR(191) NOT NULL,
    `key` VARCHAR(191) NOT NULL,
    `value` JSON NOT NULL,
    `updatedAt` DATETIME(3) NOT NULL,

    UNIQUE INDEX `SystemConfig_key_key`(`key`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateIndex
CREATE UNIQUE INDEX `User_telegramId_key` ON `User`(`telegramId`);

-- AddForeignKey
ALTER TABLE `RoundOdds` ADD CONSTRAINT `RoundOdds_roundId_fkey` FOREIGN KEY (`roundId`) REFERENCES `Round`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
