Allowed for the results page of quickvotes to be hidden while the quickvote is go
[selectricity-live] / db / create.sql
1 # CREATE elections TABLE
2 #####################################
3
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, 
10  startdate datetime, 
11  enddate datetime NOT NULL, 
12  active tinyint NOT NULL DEFAULT 0,
13  viewable tinyint NOT NULL DEFAULT 1,
14  notices tinyint NOT NULL DEFAULT 0,
15  user_id int NULL,
16  quickuser varchar(255) NULL, #stores session_id for quickvote creators
17  election_method varchar(100) DEFAULT 'ssd',
18  `type` varchar(100) NOT NULL,
19  primary key (id),
20  constraint fk_user_election foreign key (user_id) references users(id)
21 );
22
23 # CREATE candidates TABLE
24 #####################################
25
26 drop table if exists candidates;
27 create table candidates (
28  id int NOT NULL auto_increment,
29  election_id int NOT NULL,
30  name varchar(100) NOT NULL, 
31  description text NULL,
32  primary key (id)
33 );
34
35 # CREATE pictures TABLE
36 #####################################
37
38 drop table if exists pictures;
39 create table pictures (
40  id int NOT NULL auto_increment,
41  filename varchar(200),
42  data blob, 
43  filetype varchar(100), 
44  candidate_id int NULL,
45  constraint fk_candidate_picture foreign key (candidate_id) references candidates(id),
46  primary key (id)
47 );
48
49 # CREATE voters TABLE
50 #####################################
51
52 drop table if exists voters;
53 create table voters (
54  id int NOT NULL auto_increment,
55  email varchar(100) NULL, 
56  password varchar(100) NULL, 
57  contacted tinyint NOT NULL DEFAULT 0, 
58  election_id int NOT NULL, 
59  session_id varchar(32) DEFAULT NULL,
60  ipaddress varchar(32) DEFAULT NULL,
61  constraint fk_election_voter foreign key (election_id) references election(id),
62  primary key (id)
63 );
64
65
66 # CREATE tokens TABLE
67 #####################################
68
69 drop table if exists tokens;
70 create table tokens(
71  id int NOT NULL auto_increment,
72  token varchar(100) NOT NULL, 
73  vote_id int NOT NULL, 
74  constraint fk_vote_token foreign key (vote_id) references vote(id),
75  primary key (id)
76 );
77
78 # CREATE votes TABLE
79 #####################################
80
81 drop table if exists votes;
82 create table votes (
83  id int NOT NULL auto_increment,
84  voter_id int DEFAULT NULL,
85  confirmed tinyint NOT NULL DEFAULT 0,
86  time      datetime         DEFAULT NULL,
87  constraint fk_vote_voter foreign key (voter_id) references voters(id),
88  primary key (id)
89 );
90
91 # CREATE rankings TABLE
92 #####################################
93
94 drop table if exists rankings;
95 create table rankings (
96  id int NOT NULL auto_increment,
97  vote_id int DEFAULT NULL,
98  candidate_id int DEFAULT NULL,
99  rank int DEFAULT NULL,
100  primary key (id)
101 );
102
103 # CREATE users TABLE
104 #####################################
105 #DROP TABLE IF EXISTS `users`;
106 #CREATE TABLE `users` (
107 #  `id` int(11) NOT NULL auto_increment,
108 #  `login` varchar(80) NOT NULL default '',
109 #  `salted_password` varchar(40) NOT NULL default '',
110 #  `email` varchar(60) NOT NULL default '',
111 #  `firstname` varchar(40) default NULL,
112 #  `lastname` varchar(40) default NULL,
113 #  `salt` varchar(40) NOT NULL default '',
114 #  `verified` int(11) default '0',
115 #  `role` varchar(40) default NULL,
116 #  `security_token` varchar(40) default NULL,
117 #  `token_expiry` datetime default NULL,
118 #  `created_at` datetime default NULL,
119 #  `updated_at` datetime default NULL,
120 #  `logged_in_at` datetime default NULL,
121 #  `deleted` int(11) default '0',
122 #  `delete_after` datetime default NULL,
123 #  PRIMARY KEY  (`id`)
124 #) ENGINE=InnoDB DEFAULT CHARSET=latin1;
125
126 #Following is the new users table that goes with acts_as_authenticated
127 #Is simpler for now, saving the old table while in transition between 
128 #the two for ideas on what attributes may be helpful/necessary
129 drop table if exists users;
130 create table users (
131         id                        int         not null auto_increment,
132         login                     text,
133         ip                        text not null,
134         email                     text,
135         crypted_password          varchar(40),
136         salt                      varchar(40),
137         created_at                datetime,
138         updated_at                datetime,
139         remember_token            text,
140         remember_token_expires_at datetime,
141         primary key(id)
142 );

Benjamin Mako Hill || Want to submit a patch?