schema.sql 1.5 KB

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