diff --git a/e-voting-system/docker-compose.multinode.yml b/e-voting-system/docker-compose.multinode.yml index c91f4e1..2aa8a66 100644 --- a/e-voting-system/docker-compose.multinode.yml +++ b/e-voting-system/docker-compose.multinode.yml @@ -20,6 +20,7 @@ services: - evoting_data:/var/lib/mysql - ./docker/init.sql:/docker-entrypoint-initdb.d/01-init.sql - ./docker/populate_past_elections.sql:/docker-entrypoint-initdb.d/02-populate.sql + - ./docker/create_active_election.sql:/docker-entrypoint-initdb.d/03-active.sql networks: - evoting_network healthcheck: diff --git a/e-voting-system/docker-compose.yml b/e-voting-system/docker-compose.yml index 5cbcfe3..a5283df 100644 --- a/e-voting-system/docker-compose.yml +++ b/e-voting-system/docker-compose.yml @@ -20,6 +20,7 @@ services: - evoting_data:/var/lib/mysql - ./docker/init.sql:/docker-entrypoint-initdb.d/01-init.sql - ./docker/populate_past_elections.sql:/docker-entrypoint-initdb.d/02-populate.sql + - ./docker/create_active_election.sql:/docker-entrypoint-initdb.d/03-active.sql networks: - evoting_network healthcheck: diff --git a/e-voting-system/docker/create_active_election.sql b/e-voting-system/docker/create_active_election.sql new file mode 100644 index 0000000..7c98b3b --- /dev/null +++ b/e-voting-system/docker/create_active_election.sql @@ -0,0 +1,32 @@ +-- ================================================================ +-- Create ONE active election for demo (current date/time) +-- ================================================================ + +-- Insert active election (now + 24 hours) +INSERT INTO elections (name, description, start_date, end_date, elgamal_p, elgamal_g, is_active, results_published) +VALUES ( + 'Election Présidentielle 2025 - Demo', + 'Démonstration du système de vote en ligne avec blockchain', + NOW(), + DATE_ADD(NOW(), INTERVAL 24 HOUR), + 23, + 5, + TRUE, + FALSE +); + +-- Get the election ID (should be 11 if 10 past elections exist) +SET @election_id = LAST_INSERT_ID(); + +-- Insert 3 candidates for the demo election +INSERT INTO candidates (election_id, name, description, `order`) +VALUES + (@election_id, 'Alice Dupont', 'Candidate A - Progressive', 1), + (@election_id, 'Bob Martin', 'Candidate B - Centrist', 2), + (@election_id, 'Claire Laurent', 'Candidate C - Conservative', 3); + +-- Confirmation +SELECT CONCAT('✓ Active election created: ID=', @election_id) as status; +SELECT COUNT(*) as total_elections FROM elections; +SELECT * FROM elections WHERE id = @election_id; +SELECT * FROM candidates WHERE election_id = @election_id;