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.
 
 
 
 
 

230 lines
5.2 KiB

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