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 quickvote tinyint NOT NULL DEFAULT 0,
16 constraint fk_user_election foreign key (user_id) references users(id)
19 # CREATE candidates TABLE
20 #####################################
22 drop table if exists candidates;
23 create table candidates (
24 id int NOT NULL auto_increment,
25 election_id int NOT NULL,
26 name varchar(100) NOT NULL,
27 description text NULL,
28 picture_filename varchar(200),
30 picture_type varchar(100),
35 #####################################
37 drop table if exists voters;
39 id int NOT NULL auto_increment,
40 email varchar(100) NULL,
41 password varchar(100) NULL,
42 contacted tinyint NOT NULL DEFAULT 0,
43 election_id int NOT NULL,
44 session_id varchar(32) DEFAULT NULL,
45 ipaddress varchar(32) DEFAULT NULL,
46 constraint fk_election_voter foreign key (election_id) references election(id),
52 #####################################
54 drop table if exists tokens;
56 id int NOT NULL auto_increment,
57 token varchar(100) NOT NULL,
59 constraint fk_vote_token foreign key (vote_id) references vote(id),
64 #####################################
66 drop table if exists votes;
68 id int NOT NULL auto_increment,
69 voter_id int DEFAULT NULL,
70 confirmed tinyint NOT NULL DEFAULT 0,
71 time datetime DEFAULT NULL,
72 constraint fk_vote_voter foreign key (voter_id) references voters(id),
76 # CREATE rankings TABLE
77 #####################################
79 drop table if exists rankings;
80 create table rankings (
81 id int NOT NULL auto_increment,
82 vote_id int DEFAULT NULL,
83 candidate_id int DEFAULT NULL,
84 rank int DEFAULT NULL,
89 #####################################
90 #DROP TABLE IF EXISTS `users`;
91 #CREATE TABLE `users` (
92 # `id` int(11) NOT NULL auto_increment,
93 # `login` varchar(80) NOT NULL default '',
94 # `salted_password` varchar(40) NOT NULL default '',
95 # `email` varchar(60) NOT NULL default '',
96 # `firstname` varchar(40) default NULL,
97 # `lastname` varchar(40) default NULL,
98 # `salt` varchar(40) NOT NULL default '',
99 # `verified` int(11) default '0',
100 # `role` varchar(40) default NULL,
101 # `security_token` varchar(40) default NULL,
102 # `token_expiry` datetime default NULL,
103 # `created_at` datetime default NULL,
104 # `updated_at` datetime default NULL,
105 # `logged_in_at` datetime default NULL,
106 # `deleted` int(11) default '0',
107 # `delete_after` datetime default NULL,
109 #) ENGINE=InnoDB DEFAULT CHARSET=latin1;
111 #Following is the new users table that goes with acts_as_authenticated
112 #Is simpler for now, saving the old table while in transition between
113 #the two for ideas on what attributes may be helpful/necessary
114 drop table if exists users;
116 id int not null auto_increment,
120 crypted_password varchar(40),
125 remember_token_expires_at datetime,