-- ================================================================
-- Population de la base de données avec élections passées
-- 10 élections passées avec ~600 utilisateurs et leurs votes
-- ================================================================

-- Désactiver les contraintes temporairement
SET FOREIGN_KEY_CHECKS=0;

-- ================================================================
-- 1. Créer les 10 élections passées
-- ================================================================

INSERT INTO elections (name, description, start_date, end_date, elgamal_p, elgamal_g, is_active, results_published)
VALUES 
    ('Présidentielle 2020', 'Election présidentielle - Tour 1', '2020-04-10 08:00:00', '2020-04-10 20:00:00', 23, 5, FALSE, TRUE),
    ('Législatives 2020', 'Elections législatives nationales', '2020-06-07 08:00:00', '2020-06-07 19:00:00', 23, 5, FALSE, TRUE),
    ('Européennes 2019', 'Elections au Parlement européen', '2019-05-26 08:00:00', '2019-05-26 20:00:00', 23, 5, FALSE, TRUE),
    ('Régionales 2021', 'Elections régionales et départementales', '2021-06-20 08:00:00', '2021-06-20 20:00:00', 23, 5, FALSE, TRUE),
    ('Municipales 2020', 'Elections municipales', '2020-03-15 08:00:00', '2020-03-15 19:00:00', 23, 5, FALSE, TRUE),
    ('Référendum 2022', 'Référendum constitutionnel', '2022-09-04 08:00:00', '2022-09-04 20:00:00', 23, 5, FALSE, TRUE),
    ('Sénatoriales 2020', 'Election du Sénat', '2020-09-27 08:00:00', '2020-09-27 19:00:00', 23, 5, FALSE, TRUE),
    ('Présidentielle 2022', 'Election présidentielle - 2022', '2022-04-10 08:00:00', '2022-04-10 20:00:00', 23, 5, FALSE, TRUE),
    ('Locales 2023', 'Elections locales complémentaires', '2023-02-12 08:00:00', '2023-02-12 19:00:00', 23, 5, FALSE, TRUE),
    ('Référendum 2023', 'Référendum sur la réforme', '2023-07-09 08:00:00', '2023-07-09 20:00:00', 23, 5, FALSE, TRUE);

-- ================================================================
-- 2. Créer des candidats simples pour chaque élection (3-5 par élection)
-- ================================================================

-- Election 1: Présidentielle 2020
INSERT INTO candidates (election_id, name, description, `order`)
VALUES 
    (1, 'Candidat A', 'Parti de gauche', 1),
    (1, 'Candidat B', 'Parti de centre', 2),
    (1, 'Candidat C', 'Parti de droite', 3),
    (1, 'Candidat D', 'Parti écologiste', 4);

-- Election 2: Législatives 2020
INSERT INTO candidates (election_id, name, description, `order`)
VALUES 
    (2, 'Liste 1', 'Coalition de gauche', 1),
    (2, 'Liste 2', 'Majorité sortante', 2),
    (2, 'Liste 3', 'Opposition', 3);

-- Election 3: Européennes 2019
INSERT INTO candidates (election_id, name, description, `order`)
VALUES 
    (3, 'Liste PS', 'Socialistes', 1),
    (3, 'Liste LREM', 'Libéraux', 2),
    (3, 'Liste LR', 'Conservateurs', 3),
    (3, 'Liste Verts', 'Écologistes', 4),
    (3, 'Liste RN', 'Populistes', 5);

-- Election 4: Régionales 2021
INSERT INTO candidates (election_id, name, description, `order`)
VALUES 
    (4, 'Région 1 - Liste A', 'Sortante', 1),
    (4, 'Région 1 - Liste B', 'Opposition', 2),
    (4, 'Région 1 - Liste C', 'Alternative', 3);

-- Election 5: Municipales 2020
INSERT INTO candidates (election_id, name, description, `order`)
VALUES 
    (5, 'Ville - Liste Sortante', 'Équipe en place', 1),
    (5, 'Ville - Liste A', 'Opposition', 2),
    (5, 'Ville - Liste B', 'Alternatif', 3);

-- Election 6: Référendum 2022
INSERT INTO candidates (election_id, name, description, `order`)
VALUES 
    (6, 'OUI', 'Pour la réforme', 1),
    (6, 'NON', 'Contre la réforme', 2);

-- Election 7: Sénatoriales 2020
INSERT INTO candidates (election_id, name, description, `order`)
VALUES 
    (7, 'Sénateur 1', 'Parti A', 1),
    (7, 'Sénateur 2', 'Parti B', 2),
    (7, 'Sénateur 3', 'Parti C', 3);

-- Election 8: Présidentielle 2022
INSERT INTO candidates (election_id, name, description, `order`)
VALUES 
    (8, 'Sortant', 'Président sortant', 1),
    (8, 'Challenger 1', 'Candidat A', 2),
    (8, 'Challenger 2', 'Candidat B', 3),
    (8, 'Challenger 3', 'Candidat C', 4);

-- Election 9: Locales 2023
INSERT INTO candidates (election_id, name, description, `order`)
VALUES 
    (9, 'Commune A', 'Liste 1', 1),
    (9, 'Commune A', 'Liste 2', 2);

-- Election 10: Référendum 2023
INSERT INTO candidates (election_id, name, description, `order`)
VALUES 
    (10, 'OUI', 'Approbation', 1),
    (10, 'NON', 'Rejet', 2),
    (10, 'BLANC', 'Vote blanc', 3);

-- ================================================================
-- 3. Créer ~600 utilisateurs et leurs votes
-- ================================================================

-- Utilisateurs pour l'élection 1 (100 utilisateurs)
INSERT INTO voters (email, password_hash, first_name, last_name, citizen_id, has_voted, created_at)
SELECT 
    CONCAT('user_e1_', LPAD(seq.id, 3, '0'), '@voting.local') as email,
    '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/LewY5EQzS4xjT/rYa' as password_hash,
    CONCAT('FirstName', seq.id) as first_name,
    CONCAT('Election1_', seq.id) as last_name,
    CONCAT('CNI_E1_', LPAD(seq.id, 4, '0')) as citizen_id,
    TRUE as has_voted,
    DATE_SUB('2020-04-10 20:00:00', INTERVAL FLOOR(RAND() * 1000) MINUTE) as created_at
FROM (
    SELECT @row := @row + 1 as id FROM (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t1,
    (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t2,
    (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t3,
    (SELECT 0 UNION SELECT 1) t4,
    (SELECT @row:=-1) t0
) seq
WHERE seq.id < 100;

-- Utilisateurs pour l'élection 2 (100 utilisateurs)
INSERT INTO voters (email, password_hash, first_name, last_name, citizen_id, has_voted, created_at)
SELECT 
    CONCAT('user_e2_', LPAD(seq.id, 3, '0'), '@voting.local') as email,
    '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/LewY5EQzS4xjT/rYa' as password_hash,
    CONCAT('FirstName', seq.id) as first_name,
    CONCAT('Election2_', seq.id) as last_name,
    CONCAT('CNI_E2_', LPAD(seq.id, 4, '0')) as citizen_id,
    TRUE as has_voted,
    DATE_SUB('2020-06-07 19:00:00', INTERVAL FLOOR(RAND() * 1000) MINUTE) as created_at
FROM (
    SELECT @row := @row + 1 as id FROM (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t1,
    (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t2,
    (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t3,
    (SELECT 0 UNION SELECT 1) t4,
    (SELECT @row:=99) t0
) seq
WHERE seq.id < 200;

-- Utilisateurs pour l'élection 3 (100 utilisateurs)
INSERT INTO voters (email, password_hash, first_name, last_name, citizen_id, has_voted, created_at)
SELECT 
    CONCAT('user_e3_', LPAD(seq.id, 3, '0'), '@voting.local') as email,
    '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/LewY5EQzS4xjT/rYa' as password_hash,
    CONCAT('FirstName', seq.id) as first_name,
    CONCAT('Election3_', seq.id) as last_name,
    CONCAT('CNI_E3_', LPAD(seq.id, 4, '0')) as citizen_id,
    TRUE as has_voted,
    DATE_SUB('2019-05-26 20:00:00', INTERVAL FLOOR(RAND() * 1000) MINUTE) as created_at
FROM (
    SELECT @row := @row + 1 as id FROM (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t1,
    (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t2,
    (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t3,
    (SELECT 0 UNION SELECT 1) t4,
    (SELECT @row:=199) t0
) seq
WHERE seq.id < 300;

-- Utilisateurs pour l'élection 4 (100 utilisateurs)
INSERT INTO voters (email, password_hash, first_name, last_name, citizen_id, has_voted, created_at)
SELECT 
    CONCAT('user_e4_', LPAD(seq.id, 3, '0'), '@voting.local') as email,
    '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/LewY5EQzS4xjT/rYa' as password_hash,
    CONCAT('FirstName', seq.id) as first_name,
    CONCAT('Election4_', seq.id) as last_name,
    CONCAT('CNI_E4_', LPAD(seq.id, 4, '0')) as citizen_id,
    TRUE as has_voted,
    DATE_SUB('2021-06-20 20:00:00', INTERVAL FLOOR(RAND() * 1000) MINUTE) as created_at
FROM (
    SELECT @row := @row + 1 as id FROM (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t1,
    (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t2,
    (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t3,
    (SELECT 0 UNION SELECT 1) t4,
    (SELECT @row:=299) t0
) seq
WHERE seq.id < 400;

-- Utilisateurs pour l'élection 5 (100 utilisateurs)
INSERT INTO voters (email, password_hash, first_name, last_name, citizen_id, has_voted, created_at)
SELECT 
    CONCAT('user_e5_', LPAD(seq.id, 3, '0'), '@voting.local') as email,
    '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/LewY5EQzS4xjT/rYa' as password_hash,
    CONCAT('FirstName', seq.id) as first_name,
    CONCAT('Election5_', seq.id) as last_name,
    CONCAT('CNI_E5_', LPAD(seq.id, 4, '0')) as citizen_id,
    TRUE as has_voted,
    DATE_SUB('2020-03-15 19:00:00', INTERVAL FLOOR(RAND() * 1000) MINUTE) as created_at
FROM (
    SELECT @row := @row + 1 as id FROM (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t1,
    (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t2,
    (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t3,
    (SELECT 0 UNION SELECT 1) t4,
    (SELECT @row:=399) t0
) seq
WHERE seq.id < 500;

-- Utilisateurs pour l'élection 6 (60 utilisateurs)
INSERT INTO voters (email, password_hash, first_name, last_name, citizen_id, has_voted, created_at)
SELECT 
    CONCAT('user_e6_', LPAD(seq.id, 3, '0'), '@voting.local') as email,
    '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/LewY5EQzS4xjT/rYa' as password_hash,
    CONCAT('FirstName', seq.id) as first_name,
    CONCAT('Election6_', seq.id) as last_name,
    CONCAT('CNI_E6_', LPAD(seq.id, 4, '0')) as citizen_id,
    TRUE as has_voted,
    DATE_SUB('2022-09-04 20:00:00', INTERVAL FLOOR(RAND() * 1000) MINUTE) as created_at
FROM (
    SELECT @row := @row + 1 as id FROM (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t1,
    (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t2,
    (SELECT 0 UNION SELECT 1 UNION SELECT 2) t3,
    (SELECT @row:=499) t0
) seq
WHERE seq.id < 560;

-- Utilisateurs pour l'élection 7 (50 utilisateurs)
INSERT INTO voters (email, password_hash, first_name, last_name, citizen_id, has_voted, created_at)
SELECT 
    CONCAT('user_e7_', LPAD(seq.id, 3, '0'), '@voting.local') as email,
    '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/LewY5EQzS4xjT/rYa' as password_hash,
    CONCAT('FirstName', seq.id) as first_name,
    CONCAT('Election7_', seq.id) as last_name,
    CONCAT('CNI_E7_', LPAD(seq.id, 4, '0')) as citizen_id,
    TRUE as has_voted,
    DATE_SUB('2020-09-27 19:00:00', INTERVAL FLOOR(RAND() * 1000) MINUTE) as created_at
FROM (
    SELECT @row := @row + 1 as id FROM (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t1,
    (SELECT 0 UNION SELECT 1 UNION SELECT 2) t2,
    (SELECT @row:=559) t0
) seq
WHERE seq.id < 610;

-- Utilisateurs pour l'élection 8 (50 utilisateurs)
INSERT INTO voters (email, password_hash, first_name, last_name, citizen_id, has_voted, created_at)
SELECT 
    CONCAT('user_e8_', LPAD(seq.id, 3, '0'), '@voting.local') as email,
    '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/LewY5EQzS4xjT/rYa' as password_hash,
    CONCAT('FirstName', seq.id) as first_name,
    CONCAT('Election8_', seq.id) as last_name,
    CONCAT('CNI_E8_', LPAD(seq.id, 4, '0')) as citizen_id,
    TRUE as has_voted,
    DATE_SUB('2022-04-10 20:00:00', INTERVAL FLOOR(RAND() * 1000) MINUTE) as created_at
FROM (
    SELECT @row := @row + 1 as id FROM (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t1,
    (SELECT 0 UNION SELECT 1 UNION SELECT 2) t2,
    (SELECT @row:=609) t0
) seq
WHERE seq.id < 660;

-- Utilisateurs pour l'élection 9 (50 utilisateurs)
INSERT INTO voters (email, password_hash, first_name, last_name, citizen_id, has_voted, created_at)
SELECT 
    CONCAT('user_e9_', LPAD(seq.id, 3, '0'), '@voting.local') as email,
    '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/LewY5EQzS4xjT/rYa' as password_hash,
    CONCAT('FirstName', seq.id) as first_name,
    CONCAT('Election9_', seq.id) as last_name,
    CONCAT('CNI_E9_', LPAD(seq.id, 4, '0')) as citizen_id,
    TRUE as has_voted,
    DATE_SUB('2023-02-12 19:00:00', INTERVAL FLOOR(RAND() * 1000) MINUTE) as created_at
FROM (
    SELECT @row := @row + 1 as id FROM (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t1,
    (SELECT 0 UNION SELECT 1 UNION SELECT 2) t2,
    (SELECT @row:=659) t0
) seq
WHERE seq.id < 710;

-- Utilisateurs pour l'élection 10 (50 utilisateurs)
INSERT INTO voters (email, password_hash, first_name, last_name, citizen_id, has_voted, created_at)
SELECT 
    CONCAT('user_e10_', LPAD(seq.id, 3, '0'), '@voting.local') as email,
    '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/LewY5EQzS4xjT/rYa' as password_hash,
    CONCAT('FirstName', seq.id) as first_name,
    CONCAT('Election10_', seq.id) as last_name,
    CONCAT('CNI_E10_', LPAD(seq.id, 4, '0')) as citizen_id,
    TRUE as has_voted,
    DATE_SUB('2023-07-09 20:00:00', INTERVAL FLOOR(RAND() * 1000) MINUTE) as created_at
FROM (
    SELECT @row := @row + 1 as id FROM (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t1,
    (SELECT 0 UNION SELECT 1 UNION SELECT 2) t2,
    (SELECT @row:=709) t0
) seq
WHERE seq.id < 760;

-- ================================================================
-- 4. Créer les votes pour chaque utilisateur
-- ================================================================

-- Votes pour l'élection 1
INSERT INTO votes (voter_id, election_id, candidate_id, encrypted_vote, ballot_hash, timestamp)
SELECT 
    v.id as voter_id,
    1 as election_id,
    (1 + (v.id % 4)) as candidate_id,
    CONCAT('0x', MD5(CONCAT('vote_', v.id, '_', 1))) as encrypted_vote,
    SHA2(CONCAT('ballot_', v.id, '_1'), 256) as ballot_hash,
    DATE_SUB('2020-04-10 20:00:00', INTERVAL FLOOR(RAND() * 720) MINUTE) as timestamp
FROM voters v
WHERE v.email LIKE 'user_e1_%';

-- Votes pour l'élection 2
INSERT INTO votes (voter_id, election_id, candidate_id, encrypted_vote, ballot_hash, timestamp)
SELECT 
    v.id as voter_id,
    2 as election_id,
    (5 + (v.id % 3)) as candidate_id,
    CONCAT('0x', MD5(CONCAT('vote_', v.id, '_', 2))) as encrypted_vote,
    SHA2(CONCAT('ballot_', v.id, '_2'), 256) as ballot_hash,
    DATE_SUB('2020-06-07 19:00:00', INTERVAL FLOOR(RAND() * 720) MINUTE) as timestamp
FROM voters v
WHERE v.email LIKE 'user_e2_%';

-- Votes pour l'élection 3
INSERT INTO votes (voter_id, election_id, candidate_id, encrypted_vote, ballot_hash, timestamp)
SELECT 
    v.id as voter_id,
    3 as election_id,
    (8 + (v.id % 5)) as candidate_id,
    CONCAT('0x', MD5(CONCAT('vote_', v.id, '_', 3))) as encrypted_vote,
    SHA2(CONCAT('ballot_', v.id, '_3'), 256) as ballot_hash,
    DATE_SUB('2019-05-26 20:00:00', INTERVAL FLOOR(RAND() * 720) MINUTE) as timestamp
FROM voters v
WHERE v.email LIKE 'user_e3_%';

-- Votes pour l'élection 4
INSERT INTO votes (voter_id, election_id, candidate_id, encrypted_vote, ballot_hash, timestamp)
SELECT 
    v.id as voter_id,
    4 as election_id,
    (13 + (v.id % 3)) as candidate_id,
    CONCAT('0x', MD5(CONCAT('vote_', v.id, '_', 4))) as encrypted_vote,
    SHA2(CONCAT('ballot_', v.id, '_4'), 256) as ballot_hash,
    DATE_SUB('2021-06-20 20:00:00', INTERVAL FLOOR(RAND() * 720) MINUTE) as timestamp
FROM voters v
WHERE v.email LIKE 'user_e4_%';

-- Votes pour l'élection 5
INSERT INTO votes (voter_id, election_id, candidate_id, encrypted_vote, ballot_hash, timestamp)
SELECT 
    v.id as voter_id,
    5 as election_id,
    (16 + (v.id % 3)) as candidate_id,
    CONCAT('0x', MD5(CONCAT('vote_', v.id, '_', 5))) as encrypted_vote,
    SHA2(CONCAT('ballot_', v.id, '_5'), 256) as ballot_hash,
    DATE_SUB('2020-03-15 19:00:00', INTERVAL FLOOR(RAND() * 720) MINUTE) as timestamp
FROM voters v
WHERE v.email LIKE 'user_e5_%';

-- Votes pour l'élection 6
INSERT INTO votes (voter_id, election_id, candidate_id, encrypted_vote, ballot_hash, timestamp)
SELECT 
    v.id as voter_id,
    6 as election_id,
    (19 + (v.id % 2)) as candidate_id,
    CONCAT('0x', MD5(CONCAT('vote_', v.id, '_', 6))) as encrypted_vote,
    SHA2(CONCAT('ballot_', v.id, '_6'), 256) as ballot_hash,
    DATE_SUB('2022-09-04 20:00:00', INTERVAL FLOOR(RAND() * 720) MINUTE) as timestamp
FROM voters v
WHERE v.email LIKE 'user_e6_%';

-- Votes pour l'élection 7
INSERT INTO votes (voter_id, election_id, candidate_id, encrypted_vote, ballot_hash, timestamp)
SELECT 
    v.id as voter_id,
    7 as election_id,
    (21 + (v.id % 3)) as candidate_id,
    CONCAT('0x', MD5(CONCAT('vote_', v.id, '_', 7))) as encrypted_vote,
    SHA2(CONCAT('ballot_', v.id, '_7'), 256) as ballot_hash,
    DATE_SUB('2020-09-27 19:00:00', INTERVAL FLOOR(RAND() * 720) MINUTE) as timestamp
FROM voters v
WHERE v.email LIKE 'user_e7_%';

-- Votes pour l'élection 8
INSERT INTO votes (voter_id, election_id, candidate_id, encrypted_vote, ballot_hash, timestamp)
SELECT 
    v.id as voter_id,
    8 as election_id,
    (24 + (v.id % 4)) as candidate_id,
    CONCAT('0x', MD5(CONCAT('vote_', v.id, '_', 8))) as encrypted_vote,
    SHA2(CONCAT('ballot_', v.id, '_8'), 256) as ballot_hash,
    DATE_SUB('2022-04-10 20:00:00', INTERVAL FLOOR(RAND() * 720) MINUTE) as timestamp
FROM voters v
WHERE v.email LIKE 'user_e8_%';

-- Votes pour l'élection 9
INSERT INTO votes (voter_id, election_id, candidate_id, encrypted_vote, ballot_hash, timestamp)
SELECT 
    v.id as voter_id,
    9 as election_id,
    (28 + (v.id % 2)) as candidate_id,
    CONCAT('0x', MD5(CONCAT('vote_', v.id, '_', 9))) as encrypted_vote,
    SHA2(CONCAT('ballot_', v.id, '_9'), 256) as ballot_hash,
    DATE_SUB('2023-02-12 19:00:00', INTERVAL FLOOR(RAND() * 720) MINUTE) as timestamp
FROM voters v
WHERE v.email LIKE 'user_e9_%';

-- Votes pour l'élection 10
INSERT INTO votes (voter_id, election_id, candidate_id, encrypted_vote, ballot_hash, timestamp)
SELECT 
    v.id as voter_id,
    10 as election_id,
    (30 + (v.id % 3)) as candidate_id,
    CONCAT('0x', MD5(CONCAT('vote_', v.id, '_', 10))) as encrypted_vote,
    SHA2(CONCAT('ballot_', v.id, '_10'), 256) as ballot_hash,
    DATE_SUB('2023-07-09 20:00:00', INTERVAL FLOOR(RAND() * 720) MINUTE) as timestamp
FROM voters v
WHERE v.email LIKE 'user_e10_%';

-- Réactiver les contraintes
SET FOREIGN_KEY_CHECKS=1;

-- ================================================================
-- Confirmation
-- ================================================================
SELECT 'Population complète!' as status;
SELECT COUNT(*) as total_voters FROM voters;
SELECT COUNT(*) as total_elections FROM elections;
SELECT COUNT(*) as total_votes FROM votes;
