5529a318a4cacf62e26c696c6daa713bc981d8a4
[cavote.git] / schema.sql
1 drop table if exists choices;
2 drop table if exists votes;
3 drop table if exists users;
4
5 create table users (
6 id INTEGER primary key autoincrement,
7 email TEXT unique not null,
8 password TEXT not null,
9 name TEXT unique,
10 organization TEXT,
11 is_admin INTEGER default 0 not null,
12 key TEXT
13 );
14
15 create table votes (
16 id INTEGER primary key autoincrement,
17 title TEXT not null,
18 description TEXT,
19 category TEXT,
20 date_begin INTEGER default CURRENT_TIMESTAMP not null,
21 date_end INTEGER not null,
22 is_transparent INTEGER default 1 not null,
23 is_public INTEGER default 1 not null,
24 is_multiplechoice INTEGER default 1 not null,
25 is_weighted INTEGER default 0 not null,
26 is_open INTEGER default 0 not null,
27 id_author INTEGER, -- :COMMENT:maethor:120528: not null ?
28 --id_role INTEGER,
29 FOREIGN KEY(id_author) REFERENCES users(id)
30 --FOREIGN KEY(id_role) REFERENCES role(id)
31 );
32
33 create table choices (
34 id INTEGER primary key autoincrement,
35 name TEXT not null,
36 id_vote INTEGER not null,
37 FOREIGN KEY(id_vote) REFERENCES vote(id)
38 );
39
40 -- Test data
41
42 insert into users (email, password, name, organization, is_admin, key) values ("admin@admin.fr", "admin", "Toto (admin) Tata", "World corp", 1, "test");
43