schema.sql 1.2 KB

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