A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
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.
 
 
 
 
 

242 lines
6.8 KiB

  1. --
  2. -- Database: `writefreely`
  3. --
  4. -- --------------------------------------------------------
  5. --
  6. -- Table structure for table `accesstokens`
  7. --
  8. CREATE TABLE IF NOT EXISTS `accesstokens` (
  9. `token` binary(16) NOT NULL,
  10. `user_id` int(6) NOT NULL,
  11. `sudo` tinyint(1) NOT NULL DEFAULT '0',
  12. `one_time` tinyint(1) NOT NULL DEFAULT '0',
  13. `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  14. `expires` datetime DEFAULT NULL,
  15. `user_agent` varchar(255) DEFAULT NULL,
  16. PRIMARY KEY (`token`)
  17. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  18. -- --------------------------------------------------------
  19. --
  20. -- Table structure for table `appcontent`
  21. --
  22. CREATE TABLE IF NOT EXISTS `appcontent` (
  23. `id` varchar(36) NOT NULL,
  24. `content` mediumtext CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  25. `updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  26. PRIMARY KEY (`id`)
  27. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  28. -- --------------------------------------------------------
  29. --
  30. -- Table structure for table `appmigrations`
  31. --
  32. CREATE TABLE `appmigrations` (
  33. `version` int(11) NOT NULL,
  34. `migrated` datetime NOT NULL,
  35. `result` text NOT NULL
  36. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  37. -- --------------------------------------------------------
  38. --
  39. -- Table structure for table `collectionattributes`
  40. --
  41. CREATE TABLE IF NOT EXISTS `collectionattributes` (
  42. `collection_id` int(6) NOT NULL,
  43. `attribute` varchar(128) NOT NULL,
  44. `value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
  45. PRIMARY KEY (`collection_id`,`attribute`)
  46. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  47. -- --------------------------------------------------------
  48. --
  49. -- Table structure for table `collectionkeys`
  50. --
  51. CREATE TABLE IF NOT EXISTS `collectionkeys` (
  52. `collection_id` int(6) NOT NULL,
  53. `public_key` blob NOT NULL,
  54. `private_key` blob NOT NULL,
  55. PRIMARY KEY (`collection_id`)
  56. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  57. -- --------------------------------------------------------
  58. --
  59. -- Table structure for table `collectionpasswords`
  60. --
  61. CREATE TABLE IF NOT EXISTS `collectionpasswords` (
  62. `collection_id` int(6) NOT NULL,
  63. `password` char(60) NOT NULL,
  64. PRIMARY KEY (`collection_id`)
  65. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  66. -- --------------------------------------------------------
  67. --
  68. -- Table structure for table `collectionredirects`
  69. --
  70. CREATE TABLE IF NOT EXISTS `collectionredirects` (
  71. `prev_alias` varchar(100) NOT NULL,
  72. `new_alias` varchar(100) NOT NULL,
  73. PRIMARY KEY (`prev_alias`)
  74. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  75. -- --------------------------------------------------------
  76. --
  77. -- Table structure for table `collections`
  78. --
  79. CREATE TABLE IF NOT EXISTS `collections` (
  80. `id` int(6) NOT NULL AUTO_INCREMENT,
  81. `alias` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  82. `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
  83. `description` varchar(160) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
  84. `style_sheet` text,
  85. `script` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin,
  86. `format` varchar(8) DEFAULT NULL,
  87. `privacy` tinyint(1) NOT NULL,
  88. `owner_id` int(6) NOT NULL,
  89. `view_count` int(6) NOT NULL,
  90. PRIMARY KEY (`id`),
  91. UNIQUE KEY `alias` (`alias`)
  92. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  93. -- --------------------------------------------------------
  94. --
  95. -- Table structure for table `posts`
  96. --
  97. CREATE TABLE IF NOT EXISTS `posts` (
  98. `id` char(16) NOT NULL,
  99. `slug` varchar(100) DEFAULT NULL,
  100. `modify_token` char(32) DEFAULT NULL,
  101. `text_appearance` char(4) NOT NULL DEFAULT 'norm',
  102. `language` char(2) DEFAULT NULL,
  103. `rtl` tinyint(1) DEFAULT NULL,
  104. `privacy` tinyint(1) NOT NULL,
  105. `owner_id` int(6) DEFAULT NULL,
  106. `collection_id` int(6) DEFAULT NULL,
  107. `pinned_position` tinyint(1) UNSIGNED DEFAULT NULL,
  108. `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  109. `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  110. `view_count` int(6) NOT NULL,
  111. `title` varchar(160) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
  112. `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
  113. PRIMARY KEY (`id`),
  114. UNIQUE KEY `id_slug` (`collection_id`,`slug`),
  115. UNIQUE KEY `owner_id` (`owner_id`,`id`),
  116. KEY `privacy_id` (`privacy`,`id`)
  117. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  118. -- --------------------------------------------------------
  119. --
  120. -- Table structure for table `remotefollows`
  121. --
  122. CREATE TABLE IF NOT EXISTS `remotefollows` (
  123. `collection_id` int(11) NOT NULL,
  124. `remote_user_id` int(11) NOT NULL,
  125. `created` datetime NOT NULL,
  126. PRIMARY KEY (`collection_id`,`remote_user_id`)
  127. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  128. -- --------------------------------------------------------
  129. --
  130. -- Table structure for table `remoteuserkeys`
  131. --
  132. CREATE TABLE IF NOT EXISTS `remoteuserkeys` (
  133. `id` varchar(255) NOT NULL,
  134. `remote_user_id` int(11) NOT NULL,
  135. `public_key` blob NOT NULL,
  136. PRIMARY KEY (`id`),
  137. UNIQUE KEY `follower_id` (`remote_user_id`)
  138. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  139. -- --------------------------------------------------------
  140. --
  141. -- Table structure for table `remoteusers`
  142. --
  143. CREATE TABLE IF NOT EXISTS `remoteusers` (
  144. `id` int(11) NOT NULL AUTO_INCREMENT,
  145. `actor_id` varchar(255) NOT NULL,
  146. `inbox` varchar(255) NOT NULL,
  147. `shared_inbox` varchar(255) NOT NULL,
  148. PRIMARY KEY (`id`),
  149. UNIQUE KEY `collection_id` (`actor_id`)
  150. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  151. -- --------------------------------------------------------
  152. --
  153. -- Table structure for table `userattributes`
  154. --
  155. CREATE TABLE IF NOT EXISTS `userattributes` (
  156. `user_id` int(6) NOT NULL,
  157. `attribute` varchar(64) NOT NULL,
  158. `value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
  159. PRIMARY KEY (`user_id`,`attribute`)
  160. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  161. -- --------------------------------------------------------
  162. --
  163. -- Table structure for table `userinvites`
  164. --
  165. CREATE TABLE `userinvites` (
  166. `id` char(6) NOT NULL,
  167. `owner_id` int(11) NOT NULL,
  168. `max_uses` smallint(6) DEFAULT NULL,
  169. `created` datetime NOT NULL,
  170. `expires` datetime DEFAULT NULL,
  171. `inactive` tinyint(1) NOT NULL
  172. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  173. -- --------------------------------------------------------
  174. --
  175. -- Table structure for table `users`
  176. --
  177. CREATE TABLE IF NOT EXISTS `users` (
  178. `id` int(6) NOT NULL AUTO_INCREMENT,
  179. `username` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
  180. `password` char(60) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
  181. `email` varbinary(255) DEFAULT NULL,
  182. `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  183. PRIMARY KEY (`id`),
  184. UNIQUE KEY `username` (`username`)
  185. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  186. -- --------------------------------------------------------
  187. --
  188. -- Table structure for table `usersinvited`
  189. --
  190. CREATE TABLE `usersinvited` (
  191. `invite_id` char(6) NOT NULL,
  192. `user_id` int(11) NOT NULL
  193. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;