1 # CREATE elections TABLE
2 #####################################
4 drop table if exists elections;
5 create table elections (
6 id int NOT NULL auto_increment,
7 name varchar(100) NOT NULL,
8 description TEXT NOT NULL,
9 anonymous tinyint NOT NULL DEFAULT 1,
11 enddate datetime NOT NULL,
12 active tinyint NOT NULL DEFAULT 0,
14 election_method varchar(100) DEFAULT 'ssd',
15 `type` varchar(100) NOT NULL,
17 constraint fk_user_election foreign key (user_id) references users(id)
20 # CREATE candidates TABLE
21 #####################################
23 drop table if exists candidates;
24 create table candidates (
25 id int NOT NULL auto_increment,
26 election_id int NOT NULL,
27 name varchar(100) NOT NULL,
28 description text NULL,
29 picture_filename varchar(200),
31 picture_type varchar(100),
36 #####################################
38 drop table if exists voters;
40 id int NOT NULL auto_increment,
41 email varchar(100) NULL,
42 password varchar(100) NULL,
43 contacted tinyint NOT NULL DEFAULT 0,
44 election_id int NOT NULL,
45 session_id varchar(32) DEFAULT NULL,
46 ipaddress varchar(32) DEFAULT NULL,
47 constraint fk_election_voter foreign key (election_id) references election(id),
53 #####################################
55 drop table if exists tokens;
57 id int NOT NULL auto_increment,
58 token varchar(100) NOT NULL,
60 constraint fk_vote_token foreign key (vote_id) references vote(id),
65 #####################################
67 drop table if exists votes;
69 id int NOT NULL auto_increment,
70 voter_id int DEFAULT NULL,
71 confirmed tinyint NOT NULL DEFAULT 0,
72 time datetime DEFAULT NULL,
73 constraint fk_vote_voter foreign key (voter_id) references voters(id),
77 # CREATE rankings TABLE
78 #####################################
80 drop table if exists rankings;
81 create table rankings (
82 id int NOT NULL auto_increment,
83 vote_id int DEFAULT NULL,
84 candidate_id int DEFAULT NULL,
85 rank int DEFAULT NULL,
90 #####################################
91 #DROP TABLE IF EXISTS `users`;
92 #CREATE TABLE `users` (
93 # `id` int(11) NOT NULL auto_increment,
94 # `login` varchar(80) NOT NULL default '',
95 # `salted_password` varchar(40) NOT NULL default '',
96 # `email` varchar(60) NOT NULL default '',
97 # `firstname` varchar(40) default NULL,
98 # `lastname` varchar(40) default NULL,
99 # `salt` varchar(40) NOT NULL default '',
100 # `verified` int(11) default '0',
101 # `role` varchar(40) default NULL,
102 # `security_token` varchar(40) default NULL,
103 # `token_expiry` datetime default NULL,
104 # `created_at` datetime default NULL,
105 # `updated_at` datetime default NULL,
106 # `logged_in_at` datetime default NULL,
107 # `deleted` int(11) default '0',
108 # `delete_after` datetime default NULL,
110 #) ENGINE=InnoDB DEFAULT CHARSET=latin1;
112 #Following is the new users table that goes with acts_as_authenticated
113 #Is simpler for now, saving the old table while in transition between
114 #the two for ideas on what attributes may be helpful/necessary
115 drop table if exists users;
117 id int not null auto_increment,
121 crypted_password varchar(40),
126 remember_token_expires_at datetime,