CREATE TABLE `jackpot_history` (
	`id` int AUTO_INCREMENT NOT NULL,
	`jackpot_id` int NOT NULL,
	`user_id` int NOT NULL,
	`game_id` int NOT NULL,
	`win_amount` decimal(18,2) NOT NULL,
	`spin_id` varchar(64),
	`created_at` timestamp NOT NULL DEFAULT (now()),
	CONSTRAINT `jackpot_history_id` PRIMARY KEY(`id`)
);
--> statement-breakpoint
CREATE TABLE `progressive_jackpots` (
	`id` int AUTO_INCREMENT NOT NULL,
	`name` varchar(255) NOT NULL,
	`description` text,
	`current_amount` decimal(18,2) NOT NULL DEFAULT '0',
	`base_amount` decimal(18,2) NOT NULL DEFAULT '100',
	`contribution_percentage` float NOT NULL DEFAULT 0.5,
	`win_probability` float NOT NULL DEFAULT 0.0001,
	`max_win_amount` decimal(18,2),
	`is_active` boolean NOT NULL DEFAULT true,
	`game_ids` text,
	`last_won_by` int,
	`last_won_at` timestamp,
	`last_won_amount` decimal(18,2),
	`total_wins` int NOT NULL DEFAULT 0,
	`created_at` timestamp NOT NULL DEFAULT (now()),
	`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
	CONSTRAINT `progressive_jackpots_id` PRIMARY KEY(`id`)
);
--> statement-breakpoint
CREATE INDEX `idx_jackpot_history_jackpotId` ON `jackpot_history` (`jackpot_id`);--> statement-breakpoint
CREATE INDEX `idx_jackpot_history_userId` ON `jackpot_history` (`user_id`);--> statement-breakpoint
CREATE INDEX `idx_jackpot_history_createdAt` ON `jackpot_history` (`created_at`);--> statement-breakpoint
CREATE INDEX `idx_progressive_jackpots_isActive` ON `progressive_jackpots` (`is_active`);