X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28%27user_edit%27%2C%20userid=session.user.id%29%20%7D%7D?a=blobdiff_plain;f=schema.sql;h=891cf7690b64fdb7c0a1914cef0cd3604d4c0696;hb=9a0891ac3f5ae69cd1e276931401516b3213df4c;hp=11001d64d362a4fff731856a0dfeb01ff3000526;hpb=339afd3d87211040924084497951a5f7df12491b;p=cavote.git diff --git a/schema.sql b/schema.sql index 11001d6..891cf76 100644 --- a/schema.sql +++ b/schema.sql @@ -1,9 +1,10 @@ +drop table if exists user_choice; drop table if exists choices; drop table if exists attachments; drop table if exists votes; +drop table if exists user_role; drop table if exists roles; drop table if exists users; -drop table if exists user_role; create table users ( id INTEGER primary key autoincrement, @@ -48,10 +49,10 @@ create table votes ( ); create table attachments ( + id INTEGER primary key autoincrement, url TEXT not null, id_vote INTEGER not null, - FOREIGN KEY(id_vote) REFERENCES vote(id), - PRIMARY KEY(url, id_vote) + FOREIGN KEY(id_vote) REFERENCES vote(id) ); create table choices ( @@ -61,6 +62,15 @@ create table choices ( FOREIGN KEY(id_vote) REFERENCES vote(id) ); +create table user_choice ( + id_user INTEGER, + id_choice INTEGER, + weight INTEGER, + FOREIGN KEY(id_user) REFERENCES users(id), + FOREIGN KEY(id_choice) REFERENCES choices(id), + PRIMARY KEY(id_user, id_choice) +); + -- Test data insert into users (email, password, name, organization, is_admin, key) values ("admin@admin.fr", "d033e22ae348aeb5660fc2140aec35850c4da997", "Toto (admin) Tata", "World corp", 1, "test"); -- mdp = admin