Added the RoR Login-Engine and activated it on the site.
[selectricity] / db / create.sql
1 # CREATE users TABLE
2 #####################################
3
4 #drop table if exists users;
5 #create table users (
6 # id int NOT NULL auto_increment,
7 # login varchar(80) default NULL,
8 # password varchar(40) default NULL,
9 # primary key (id)
10 #);
11
12 ## Create a default system user to own stage directions
13 ## and similar. Users cannot log in.
14 #insert into users ( id, login ) values ( 1, "System Defaults" );
15
16 # CREATE elections TABLE
17 #####################################
18
19 drop table if exists elections;
20 create table elections (
21  id int NOT NULL auto_increment,
22  name varchar(100) NOT NULL, 
23  description TEXT NOT NULL, 
24  anonymous tinyint NOT NULL DEFAULT 0, 
25  startdate datetime NOT NULL, 
26  enddate datetime, 
27  primary key (id)
28 );
29
30 # CREATE candidates TABLE
31 #####################################
32
33 drop table if exists candidates;
34 create table candidates (
35  id int NOT NULL auto_increment,
36  election_id int NOT NULL,
37  name varchar(100) NOT NULL, 
38  picture blob NOT NULL, 
39  primary key (id)
40 );
41
42 # CREATE voters TABLE
43 #####################################
44
45 drop table if exists voters;
46 create table voters (
47  id int NOT NULL auto_increment,
48  email varchar(100) NOT NULL, 
49  password varchar(100) NOT NULL, 
50  contacted tinyint NOT NULL DEFAULT 0, 
51  election_id int NOT NULL, 
52  constraint fk_election_voter foreign key (election_id) references election(id),
53  primary key (id)
54 );
55
56 # CREATE tokens TABLE
57 #####################################
58
59 drop table if exists tokens;
60 create table tokens(
61  id int NOT NULL auto_increment,
62  token varchar(100) NOT NULL, 
63  vote_id int NOT NULL, 
64  constraint fk_vote_token foreign key (vote_id) references vote(id),
65  primary key (id)
66 );
67
68 # CREATE votes TABLE
69 #####################################
70
71 drop table if exists votes;
72 create table votes (
73  id int NOT NULL auto_increment,
74  voter_id int DEFAULT NULL,
75  confirmed tinyint NOT NULL DEFAULT 0,
76  constraint fk_vote_voter foreign key (voter_id) references voters(id),
77  primary key (id)
78 );
79
80 # CREATE rankings TABLE
81 #####################################
82
83 drop table if exists rankings;
84 create table rankings (
85  id int NOT NULL auto_increment,
86  vote_id int DEFAULT NULL,
87  candidate_id int DEFAULT NULL,
88  rank int DEFAULT NULL,
89  primary key (id)
90 );
91
92 # CREATE users TABLE
93 #####################################
94 DROP TABLE IF EXISTS `users`;
95 CREATE TABLE `users` (
96   `id` int(11) NOT NULL auto_increment,
97   `login` varchar(80) NOT NULL default '',
98   `salted_password` varchar(40) NOT NULL default '',
99   `email` varchar(60) NOT NULL default '',
100   `firstname` varchar(40) default NULL,
101   `lastname` varchar(40) default NULL,
102   `salt` varchar(40) NOT NULL default '',
103   `verified` int(11) default '0',
104   `role` varchar(40) default NULL,
105   `security_token` varchar(40) default NULL,
106   `token_expiry` datetime default NULL,
107   `created_at` datetime default NULL,
108   `updated_at` datetime default NULL,
109   `logged_in_at` datetime default NULL,
110   `deleted` int(11) default '0',
111   `delete_after` datetime default NULL,
112   PRIMARY KEY  (`id`)
113 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
114

Benjamin Mako Hill || Want to submit a patch?