I have added the acts_as_authenticated plugin to code, and have gotten VERY BASIC...
[selectricity] / 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  user_id int NULL,
14  quickvote tinyint NOT NULL DEFAULT 0,
15  primary key (id),
16  constraint fk_user_election foreign key (user_id) references users(id)
17 );
18
19 # CREATE candidates TABLE
20 #####################################
21
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),
29  picture_data blob, 
30  picture_type varchar(100), 
31  primary key (id)
32 );
33
34 # CREATE voters TABLE
35 #####################################
36
37 drop table if exists voters;
38 create table 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),
47  primary key (id)
48 );
49
50
51 # CREATE tokens TABLE
52 #####################################
53
54 drop table if exists tokens;
55 create table tokens(
56  id int NOT NULL auto_increment,
57  token varchar(100) NOT NULL, 
58  vote_id int NOT NULL, 
59  constraint fk_vote_token foreign key (vote_id) references vote(id),
60  primary key (id)
61 );
62
63 # CREATE votes TABLE
64 #####################################
65
66 drop table if exists votes;
67 create table votes (
68  id int NOT NULL auto_increment,
69  voter_id int DEFAULT NULL,
70  confirmed tinyint NOT NULL DEFAULT 0,
71  constraint fk_vote_voter foreign key (voter_id) references voters(id),
72  primary key (id)
73 );
74
75 # CREATE rankings TABLE
76 #####################################
77
78 drop table if exists rankings;
79 create table rankings (
80  id int NOT NULL auto_increment,
81  vote_id int DEFAULT NULL,
82  candidate_id int DEFAULT NULL,
83  rank int DEFAULT NULL,
84  primary key (id)
85 );
86
87 # CREATE users TABLE
88 #####################################
89 #DROP TABLE IF EXISTS `users`;
90 #CREATE TABLE `users` (
91 #  `id` int(11) NOT NULL auto_increment,
92 #  `login` varchar(80) NOT NULL default '',
93 #  `salted_password` varchar(40) NOT NULL default '',
94 #  `email` varchar(60) NOT NULL default '',
95 #  `firstname` varchar(40) default NULL,
96 #  `lastname` varchar(40) default NULL,
97 #  `salt` varchar(40) NOT NULL default '',
98 #  `verified` int(11) default '0',
99 #  `role` varchar(40) default NULL,
100 #  `security_token` varchar(40) default NULL,
101 #  `token_expiry` datetime default NULL,
102 #  `created_at` datetime default NULL,
103 #  `updated_at` datetime default NULL,
104 #  `logged_in_at` datetime default NULL,
105 #  `deleted` int(11) default '0',
106 #  `delete_after` datetime default NULL,
107 #  PRIMARY KEY  (`id`)
108 #) ENGINE=InnoDB DEFAULT CHARSET=latin1;
109
110 #Following is the new users table that goes with acts_as_authenticated
111 #Is simpler for now, saving the old table while in transition between 
112 #the two for ideas on what attributes may be helpful/necessary
113 drop table if exists users;
114 create table users (
115         id                        int         not null auto_increment,
116         login                     text,
117         ip                        text not null,
118         email                     text,
119         crypted_password          varchar(40),
120         salt                      varchar(40),
121         created_at                datetime,
122         updated_at                datetime,
123         remember_token            text,
124         remember_token_expires_at datetime,
125         primary key(id)
126 );

Benjamin Mako Hill || Want to submit a patch?