schema.sql 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. drop table if exists choices;
  2. drop table if exists votes;
  3. drop table if exists roles;
  4. drop table if exists users;
  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. create table roles (
  15. id INTEGER primary key autoincrement,
  16. name TEXT
  17. );
  18. create table votes (
  19. id INTEGER primary key autoincrement,
  20. title TEXT not null,
  21. description TEXT,
  22. category TEXT,
  23. date_begin INTEGER default CURRENT_TIMESTAMP not null,
  24. date_end INTEGER not null,
  25. is_transparent INTEGER default 1 not null,
  26. is_public INTEGER default 1 not null,
  27. is_multiplechoice INTEGER default 1 not null,
  28. is_weighted INTEGER default 0 not null,
  29. is_open INTEGER default 0 not null,
  30. id_author INTEGER, -- :COMMENT:maethor:120528: not null ?
  31. id_role INTEGER default 1 not null,
  32. FOREIGN KEY(id_author) REFERENCES users(id)
  33. FOREIGN KEY(id_role) REFERENCES roles(id)
  34. );
  35. create table choices (
  36. id INTEGER primary key autoincrement,
  37. name TEXT not null,
  38. id_vote INTEGER not null,
  39. FOREIGN KEY(id_vote) REFERENCES vote(id)
  40. );
  41. -- Test data
  42. insert into users (email, password, name, organization, is_admin, key) values ("admin@admin.fr", "admin", "Toto (admin) Tata", "World corp", 1, "test");
  43. insert into roles (id, name) values (1, "Tous");
  44. insert into roles (name) values ("CA");
  45. insert into roles (name) values ("Members");