-- Seed original VRBattles data from PHP database
-- Note: Passwords are MD5 hashed - users will need to reset passwords or we support legacy login

-- Insert users (preserving original IDs)
INSERT INTO users (id, date_registered, firstname, lastname, username, email, password, is_admin, profile) VALUES
(2, '2022-01-06 11:17:59', 'Son', 'Goku', 'songoku', 'judithcharisma1978@gmail.com', '827ccb0eea8a706c4c34a16891f84e7b', FALSE, '1647586376.png'),
(3, '2022-01-06 11:27:51', 'Game', 'Admin', 'admin', 'admin@gmail.com', '827ccb0eea8a706c4c34a16891f84e7b', TRUE, '1647586388.png'),
(8, '2022-02-10 13:02:05', 'Test', 'Player', 'tester', 'test@gmail.com', '827ccb0eea8a706c4c34a16891f84e7b', FALSE, '1647586403.png'),
(9, '2022-02-15 20:14:00', 'Demo', 'Player', 'demo', 'demo@gmail.com', '827ccb0eea8a706c4c34a16891f84e7b', FALSE, '1647586441.png'),
(10, '2022-02-15 20:18:07', 'Mark', 'Jimenez', 'markjimenez', 'markjimenez@gmail.com', '827ccb0eea8a706c4c34a16891f84e7b', FALSE, '1647586416.png'),
(15, '2022-03-14 13:56:56', 'Crysthel', 'Triones', 'crysthel', 'crysthelanndelostrinos1234@gmail.com', '827ccb0eea8a706c4c34a16891f84e7b', FALSE, '1647586426.png'),
(16, '2022-03-21 11:56:43', 'crazy', 'coder', 'crazycoder', 'crazycoder09@gmail.com', 'e10adc3949ba59abbe56e057f20f883e', FALSE, NULL),
(17, '2022-03-30 17:57:12', 'tony', 'stark', 'mark47', 'mark47@gmail.com', 'e10adc3949ba59abbe56e057f20f883e', FALSE, NULL)
ON CONFLICT (id) DO NOTHING;

-- Reset sequence to continue after max id
SELECT setval('users_id_seq', (SELECT MAX(id) FROM users));

-- Insert teams (preserving original IDs)
INSERT INTO teams (id, date_created, name, logo, bio, rank, mmr, is_delete) VALUES
(15, '2022-02-11 17:09:16', 'Black Ninja', '1647586615.png', 'Together we stand, Divided we fall!', 1, 1000, FALSE),
(16, '2022-02-15 20:19:11', 'Cubers', '1647586637.png', 'Run to death', 2, 1000, FALSE),
(40, '2022-02-25 15:30:37', 'Team Warzone', '1647586662.png', 'Best of the best', 3, 1000, FALSE)
ON CONFLICT (id) DO NOTHING;

-- Reset sequence
SELECT setval('teams_id_seq', (SELECT MAX(id) FROM teams));

-- Insert team players (preserving original IDs)
INSERT INTO team_players (id, date_created, team_id, player_id, position, status) VALUES
(24, '2022-02-15 20:19:12', 16, 10, 'captain', 1),
(28, '2022-02-18 18:09:30', 15, 9, 'co-captain', 1),
(43, '2022-02-25 15:30:37', 40, 8, 'captain', 1)
ON CONFLICT (id) DO NOTHING;

-- Reset sequence
SELECT setval('team_players_id_seq', (SELECT MAX(id) FROM team_players));

-- Insert ladders (preserving original IDs)
INSERT INTO ladders (id, date_created, date_expiration, date_start, created_by_id, name, status, logo) VALUES
(10, '2022-02-24 15:46:57', '2022-02-25', '2022-02-25', 0, 'Mighty Worlds', 0, '1647574565.png'),
(11, '2022-02-24 15:53:14', '2022-02-25', '2022-02-25', 8, 'Hardcores', 0, '1647574578.png'),
(12, '2022-02-24 16:43:41', '2022-02-24', '2022-02-24', 8, 'King of the Hill', 0, '1647574590.png'),
(15, '2022-02-25 14:50:28', '2022-02-25', '2022-02-25', 3, 'World Dominator', 0, '1647574600.png'),
(16, '2022-02-25 14:51:19', '2022-02-25', '2022-02-25', 3, 'Upcoming Ladder', 0, '1647574613.png'),
(19, '2022-02-25 15:06:29', '2022-02-25', '2022-02-25', 3, 'Mighty Kids', 1, NULL),
(22, '2022-02-25 15:10:20', '2022-02-25', '2022-02-25', 3, 'The Constructors', 1, NULL),
(23, '2022-02-25 15:29:02', '2022-02-25', '2022-02-23', 8, 'Fools', 1, NULL)
ON CONFLICT (id) DO NOTHING;

-- Reset sequence
SELECT setval('ladders_id_seq', (SELECT MAX(id) FROM ladders));

-- Insert ladder_teams (preserving original IDs)
INSERT INTO ladder_teams (id, date_created, ladder_id, team_id) VALUES
(4, '2022-03-18 17:19:44', 10, 15),
(5, '2022-03-18 17:21:17', 11, 15),
(6, '2022-03-18 17:21:24', 12, 15),
(7, '2022-03-18 17:21:34', 15, 15),
(8, '2022-03-18 17:21:53', 10, 16),
(9, '2022-03-18 17:21:57', 11, 16),
(10, '2022-03-18 17:22:21', 11, 40),
(11, '2022-03-18 17:22:25', 12, 40),
(12, '2022-03-18 17:22:29', 15, 40),
(13, '2022-03-18 17:22:37', 16, 40)
ON CONFLICT (id) DO NOTHING;

-- Reset sequence
SELECT setval('ladder_teams_id_seq', (SELECT MAX(id) FROM ladder_teams));

-- Insert matches (preserving original IDs)
INSERT INTO matches (id, date_created, date_start, created_by_id, challenge_date, team_id_1, team_id_2, team_1_status, team_2_status, matche_status) VALUES
(53, '2022-03-30 19:02:00', '2022-03-30 19:01:00', 10, '2022-04-07 16:59:00', 40, 16, 3, 3, 0),
(54, '2022-04-01 17:51:11', '2022-04-01 17:51:00', 8, '2022-04-01 17:51:00', 15, 40, 0, 1, 0)
ON CONFLICT (id) DO NOTHING;

-- Reset sequence
SELECT setval('matches_id_seq', (SELECT MAX(id) FROM matches));

-- Insert featured_players (preserving original IDs)
INSERT INTO featured_players (id, date_created, player_id, rank) VALUES
(1, '2022-03-18 15:07:22', 2, 1),
(2, '2022-03-18 15:07:22', 8, 2),
(3, '2022-03-18 15:07:33', 9, 3)
ON CONFLICT (id) DO NOTHING;

-- Reset sequence
SELECT setval('featured_players_id_seq', (SELECT MAX(id) FROM featured_players));
