The backend for the AiteStory website
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.5 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. # DROP TABLE page; DROP TABLE; USER
  2. CREATE TABLE user (
  3. `id` CHAR(32) PRIMARY KEY,
  4. `role` CHAR(16),
  5. INDEX(role)
  6. );
  7. INSERT INTO user (id, role) VALUES("test:Test", "restricted")
  8. CREATE TABLE page (
  9. `id` CHAR(16) NOT NULL PRIMARY KEY,
  10. `name` VARCHAR(255) NOT NULL,
  11. `author` VARCHAR(64),
  12. `category` VARCHAR(16) NOT NULL,
  13. `fictional_date` DATETIME NOT NULL,
  14. `publish_date` DATETIME NOT NULL,
  15. `edit_date` DATETIME NOT NULL,
  16. `dated` BOOLEAN NOT NULL,
  17. `published` BOOLEAN NOT NULL,
  18. `unlisted` BOOLEAN NOT NULL,
  19. `specific` BOOLEAN NOT NULL,
  20. `indexed` BOOLEAN NOT NULL,
  21. `type` VARCHAR(16) NOT NULL,
  22. `source` MEDIUMTEXT NOT NULL,
  23. `background_url` VARCHAR(255),
  24. FOREIGN KEY (`author`) REFERENCES user(`id`) ON DELETE SET NULL
  25. );
  26. CREATE TABLE tag (
  27. `id` CHAR(24) NOT NULL PRIMARY KEY,
  28. `type` CHAR(16) NOT NULL,
  29. `disabled` BOOLEAN NOT NULL,
  30. `name` VARCHAR(64) NOT NULL,
  31. UNIQUE(name),
  32. INDEX(disabled)
  33. );
  34. CREATE TABLE page_tag (
  35. `page_id` CHAR(16) NOT NULL,
  36. `tag_id` CHAR(24) NOT NULL,
  37. `primary` BOOLEAN NOT NULL,
  38. PRIMARY KEY (`page_id`, `tag_id`),
  39. FOREIGN KEY (`page_id`) REFERENCES page(`id`) ON DELETE CASCADE,
  40. FOREIGN KEY (`tag_id`) REFERENCES tag(`id`) ON DELETE CASCADE
  41. );
  42. CREATE TABLE page_unread (
  43. `page_id` CHAR(16) NOT NULL,
  44. `user_id` CHAR(32) NOT NULL,
  45. PRIMARY KEY (`page_id`, `user_id`),
  46. FOREIGN KEY (`page_id`) REFERENCES page(`id`) ON DELETE CASCADE,
  47. FOREIGN KEY (`user_id`) REFERENCES user(`id`) ON DELETE CASCADE
  48. );