fix: Add active election to database initialization for demo
This commit is contained in:
parent
da7812835e
commit
b8fa1a4b95
@ -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:
|
||||
|
||||
@ -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:
|
||||
|
||||
32
e-voting-system/docker/create_active_election.sql
Normal file
32
e-voting-system/docker/create_active_election.sql
Normal file
@ -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;
|
||||
Loading…
x
Reference in New Issue
Block a user