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