-- Seed data for BGMI Tournament App
-- NOTE: Passwords are bcrypt-hashed. Admin password is 'Admin@123'.
-- Run after running migrate.sql

START TRANSACTION;

-- Clear existing data (safe in dev). Comment out if you want to keep data.
-- SET FOREIGN_KEY_CHECKS = 0;
-- TRUNCATE TABLE registrations;
-- TRUNCATE TABLE transactions;
-- TRUNCATE TABLE withdraw_requests;
-- TRUNCATE TABLE notifications;
-- TRUNCATE TABLE tournaments;
-- TRUNCATE TABLE users;
-- SET FOREIGN_KEY_CHECKS = 1;

-- Admin user (email: admin@demo.com / password: Admin@123)
-- Bcrypt hash generated via PHP password_hash('Admin@123', PASSWORD_BCRYPT)
SET @admin_pass = '$2y$10$gk0cVq9H8u2JgqQ2X1xwUuXn1Zrj7Qj2kJg2F2bR0b8s9o1Bv6QyK';
INSERT INTO users (name, email, password, is_admin, email_verified, created_at)
VALUES ('Admin', 'admin@demo.com', @admin_pass, 1, 1, NOW());

-- 20 sample users (password same as admin for convenience)
INSERT INTO users (name, email, password, bgmi_id, created_at)
VALUES
('User 1','user1@demo.com', @admin_pass, 'BGMI0001', NOW()),
('User 2','user2@demo.com', @admin_pass, 'BGMI0002', NOW()),
('User 3','user3@demo.com', @admin_pass, 'BGMI0003', NOW()),
('User 4','user4@demo.com', @admin_pass, 'BGMI0004', NOW()),
('User 5','user5@demo.com', @admin_pass, 'BGMI0005', NOW()),
('User 6','user6@demo.com', @admin_pass, 'BGMI0006', NOW()),
('User 7','user7@demo.com', @admin_pass, 'BGMI0007', NOW()),
('User 8','user8@demo.com', @admin_pass, 'BGMI0008', NOW()),
('User 9','user9@demo.com', @admin_pass, 'BGMI0009', NOW()),
('User 10','user10@demo.com', @admin_pass, 'BGMI0010', NOW()),
('User 11','user11@demo.com', @admin_pass, 'BGMI0011', NOW()),
('User 12','user12@demo.com', @admin_pass, 'BGMI0012', NOW()),
('User 13','user13@demo.com', @admin_pass, 'BGMI0013', NOW()),
('User 14','user14@demo.com', @admin_pass, 'BGMI0014', NOW()),
('User 15','user15@demo.com', @admin_pass, 'BGMI0015', NOW()),
('User 16','user16@demo.com', @admin_pass, 'BGMI0016', NOW()),
('User 17','user17@demo.com', @admin_pass, 'BGMI0017', NOW()),
('User 18','user18@demo.com', @admin_pass, 'BGMI0018', NOW()),
('User 19','user19@demo.com', @admin_pass, 'BGMI0019', NOW()),
('User 20','user20@demo.com', @admin_pass, 'BGMI0020', NOW());

-- 10 tournaments: 8 upcoming, 2 completed
INSERT INTO tournaments (name, date_time, entry_fee, prize_pool, max_players, status, created_at)
VALUES
('BGMI Showdown #1', NOW() + INTERVAL 1 DAY, 50.00, 500.00, 100, 'upcoming', NOW()),
('BGMI Night Ops', NOW() + INTERVAL 2 DAY, 0.00, 250.00, 100, 'upcoming', NOW()),
('Desert Clash', NOW() + INTERVAL 3 DAY, 20.00, 200.00, 50, 'upcoming', NOW()),
('Urban Frenzy', NOW() + INTERVAL 4 DAY, 30.00, 300.00, 80, 'upcoming', NOW()),
('Jungle Mayhem', NOW() + INTERVAL 5 DAY, 10.00, 150.00, 60, 'upcoming', NOW()),
('Skyfall Arena', NOW() + INTERVAL 6 DAY, 40.00, 400.00, 100, 'upcoming', NOW()),
('Frostbite Cup', NOW() + INTERVAL 7 DAY, 25.00, 250.00, 70, 'upcoming', NOW()),
('Thunder Royale', NOW() + INTERVAL 8 DAY, 15.00, 180.00, 60, 'upcoming', NOW()),
('Retro Rumble', NOW() - INTERVAL 10 DAY, 20.00, 200.00, 50, 'completed', NOW()),
('Neon Nights', NOW() - INTERVAL 5 DAY, 35.00, 350.00, 80, 'completed', NOW());

-- Sample registrations: Users 1-10 register for tournaments 1-3; Users 11-15 for tournament 9 (completed)
INSERT INTO registrations (user_id, tournament_id, result, winnings, created_at)
VALUES
(2, 1, NULL, 0.00, NOW()),
(3, 1, NULL, 0.00, NOW()),
(4, 1, NULL, 0.00, NOW()),
(5, 1, NULL, 0.00, NOW()),
(6, 2, NULL, 0.00, NOW()),
(7, 2, NULL, 0.00, NOW()),
(8, 2, NULL, 0.00, NOW()),
(9, 3, NULL, 0.00, NOW()),
(10, 3, NULL, 0.00, NOW()),
(11, 3, NULL, 0.00, NOW()),
(12, 9, 'Top 1', 100.00, NOW()),
(13, 9, 'Top 3', 50.00, NOW()),
(14, 9, 'Top 5', 25.00, NOW()),
(15, 9, NULL, 0.00, NOW());

-- Sample transactions: add funds, entry fees, winnings
INSERT INTO transactions (user_id, type, amount, meta, created_at)
VALUES
(2, 'add', 200.00, JSON_OBJECT('method','razorpay'), NOW()),
(2, 'entry_fee', 50.00, JSON_OBJECT('tournament_id', 1), NOW()),
(3, 'add', 150.00, JSON_OBJECT('method','razorpay'), NOW()),
(3, 'entry_fee', 50.00, JSON_OBJECT('tournament_id', 1), NOW()),
(12, 'winning', 100.00, JSON_OBJECT('tournament_id', 9), NOW()),
(13, 'winning', 50.00, JSON_OBJECT('tournament_id', 9), NOW());

COMMIT;
