2013-12-18 20:38:02 +00:00
|
|
|
DROP TABLE IF EXISTS `elections`;
|
2009-06-04 18:15:43 +00:00
|
|
|
CREATE TABLE `elections` (
|
|
|
|
`id` int(11) NOT NULL auto_increment,
|
|
|
|
`type` enum('elections','referendum') NOT NULL default 'elections',
|
|
|
|
`name` varchar(150) NOT NULL default '',
|
|
|
|
`voting_start` datetime default NULL,
|
|
|
|
`voting_end` datetime default '0000-00-00 00:00:00',
|
|
|
|
`choices_nb` int(11) NOT NULL default '0',
|
|
|
|
`question` text NOT NULL,
|
2013-12-18 20:38:02 +00:00
|
|
|
PRIMARY KEY (`id`));
|
|
|
|
DROP TABLE IF EXISTS `election_anon_tokens`;
|
2009-06-04 18:15:43 +00:00
|
|
|
CREATE TABLE `election_anon_tokens` (
|
|
|
|
`id` int(11) NOT NULL auto_increment,
|
|
|
|
`anon_token` varchar(200) NOT NULL default '',
|
|
|
|
`election_id` int(11) NOT NULL default '0',
|
|
|
|
PRIMARY KEY (`id`)
|
2013-12-18 20:38:02 +00:00
|
|
|
) ENGINE=InnoDB AUTO_INCREMENT=903 DEFAULT CHARSET=utf8;
|
|
|
|
DROP TABLE IF EXISTS `election_choices`;
|
2009-06-04 18:15:43 +00:00
|
|
|
CREATE TABLE `election_choices` (
|
|
|
|
`id` int(11) NOT NULL auto_increment,
|
|
|
|
`election_id` int(11) NOT NULL default '0',
|
|
|
|
`choice` varchar(150) NOT NULL default '',
|
|
|
|
PRIMARY KEY (`id`)
|
2013-12-18 20:38:02 +00:00
|
|
|
) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8 ;
|
2014-02-10 17:17:32 +00:00
|
|
|
|
2014-02-10 22:03:53 +00:00
|
|
|
/* The election_results table stores the HTML output from the openstv command.
|
|
|
|
** It must be inserted manually at the end of the election.
|
|
|
|
*/
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS `election_results`;
|
|
|
|
CREATE TABLE `election_results` (
|
2014-02-10 23:32:23 +00:00
|
|
|
`election_id` int(11) NOT NULL UNIQUE default '0',
|
2014-02-10 22:03:53 +00:00
|
|
|
`result` text
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
|
|
|
|
|
2014-02-10 17:17:32 +00:00
|
|
|
/* Data in election_tmp_tokens only lives while the election is ongoing, and
|
|
|
|
** the PHP code deletes these entries when it records votes.
|
|
|
|
*/
|
|
|
|
|
2013-12-18 20:38:02 +00:00
|
|
|
DROP TABLE IF EXISTS `election_tmp_tokens`;
|
2009-06-04 18:15:43 +00:00
|
|
|
CREATE TABLE `election_tmp_tokens` (
|
|
|
|
`election_id` int(11) NOT NULL default '0',
|
|
|
|
`member_id` int(11) NOT NULL default '0',
|
|
|
|
`tmp_token` varchar(200) NOT NULL default ''
|
2013-12-18 20:38:02 +00:00
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
2009-06-04 18:15:43 +00:00
|
|
|
|
2013-12-18 23:53:50 +00:00
|
|
|
/* Not good normal form in election_voters table; there will be duplicates on
|
|
|
|
** the email_address, but we think of a election_voter_id as a identity tied a
|
|
|
|
** specific election. */
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS `election_voters`;
|
|
|
|
CREATE TABLE `election_voters` (
|
|
|
|
`id` int(11) NOT NULL auto_increment,
|
|
|
|
`election_id` int(11) NOT NULL default '0',
|
2014-02-10 17:27:07 +00:00
|
|
|
`email_address` varchar(500) NOT NULL default '',
|
2013-12-18 23:53:50 +00:00
|
|
|
PRIMARY KEY (`id`));
|
|
|
|
|
|
|
|
|
2009-06-04 18:15:43 +00:00
|
|
|
/*
|
2013-12-18 23:53:50 +00:00
|
|
|
from each voter we prepare anon tokens
|
2009-06-04 18:15:43 +00:00
|
|
|
then insert those anon tokens to database
|
|
|
|
of course before a new election record should be created since its id is needed for anon_tokens
|
|
|
|
and election_choices are to be inserted
|
|
|
|
rest is handled by itself iirc
|
|
|
|
<bolsh> There's "election_votes" and "foundationmembers" too
|
|
|
|
I'm not sure if there's a join done between foundationmembers and the other tables
|
|
|
|
*/
|
|
|
|
|
2013-12-18 20:38:02 +00:00
|
|
|
DROP TABLE IF EXISTS `election_votes`;
|
2009-06-04 18:15:43 +00:00
|
|
|
CREATE TABLE `election_votes` (
|
|
|
|
`id` int(11) NOT NULL auto_increment,
|
|
|
|
`choice_id` int(11) NOT NULL default '0',
|
|
|
|
`anon_id` int(11) NOT NULL default '0',
|
2013-12-18 23:47:16 +00:00
|
|
|
`preference` int(11) NOT NULL default '0',
|
2013-12-18 20:38:02 +00:00
|
|
|
PRIMARY KEY (`id`));
|
2009-06-04 18:15:43 +00:00
|
|
|
|