schema.rb 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331
  1. # This file is auto-generated from the current state of the database. Instead
  2. # of editing this file, please use the migrations feature of Active Record to
  3. # incrementally modify your database, and then regenerate this schema definition.
  4. #
  5. # This file is the source Rails uses to define your schema when running `bin/rails
  6. # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
  7. # be faster and is potentially less error prone than running all of your
  8. # migrations from scratch. Old migrations may fail to apply correctly if those
  9. # migrations use external dependencies or application code.
  10. #
  11. # It's strongly recommended that you check this file into your version control system.
  12. ActiveRecord::Schema.define(version: 2022_12_06_114142) do
  13. # These are extensions that must be enabled in order to support this database
  14. enable_extension "plpgsql"
  15. create_table "account_aliases", force: :cascade do |t|
  16. t.bigint "account_id"
  17. t.string "acct", default: "", null: false
  18. t.string "uri", default: "", null: false
  19. t.datetime "created_at", null: false
  20. t.datetime "updated_at", null: false
  21. t.index ["account_id"], name: "index_account_aliases_on_account_id"
  22. end
  23. create_table "account_conversations", force: :cascade do |t|
  24. t.bigint "account_id"
  25. t.bigint "conversation_id"
  26. t.bigint "participant_account_ids", default: [], null: false, array: true
  27. t.bigint "status_ids", default: [], null: false, array: true
  28. t.bigint "last_status_id"
  29. t.integer "lock_version", default: 0, null: false
  30. t.boolean "unread", default: false, null: false
  31. t.index ["account_id", "conversation_id", "participant_account_ids"], name: "index_unique_conversations", unique: true
  32. t.index ["conversation_id"], name: "index_account_conversations_on_conversation_id"
  33. end
  34. create_table "account_deletion_requests", force: :cascade do |t|
  35. t.bigint "account_id"
  36. t.datetime "created_at", null: false
  37. t.datetime "updated_at", null: false
  38. t.index ["account_id"], name: "index_account_deletion_requests_on_account_id"
  39. end
  40. create_table "account_domain_blocks", force: :cascade do |t|
  41. t.string "domain"
  42. t.datetime "created_at", null: false
  43. t.datetime "updated_at", null: false
  44. t.bigint "account_id"
  45. t.index ["account_id", "domain"], name: "index_account_domain_blocks_on_account_id_and_domain", unique: true
  46. end
  47. create_table "account_migrations", force: :cascade do |t|
  48. t.bigint "account_id"
  49. t.string "acct", default: "", null: false
  50. t.bigint "followers_count", default: 0, null: false
  51. t.bigint "target_account_id"
  52. t.datetime "created_at", null: false
  53. t.datetime "updated_at", null: false
  54. t.index ["account_id"], name: "index_account_migrations_on_account_id"
  55. t.index ["target_account_id"], name: "index_account_migrations_on_target_account_id", where: "(target_account_id IS NOT NULL)"
  56. end
  57. create_table "account_moderation_notes", force: :cascade do |t|
  58. t.text "content", null: false
  59. t.bigint "account_id", null: false
  60. t.bigint "target_account_id", null: false
  61. t.datetime "created_at", null: false
  62. t.datetime "updated_at", null: false
  63. t.index ["account_id"], name: "index_account_moderation_notes_on_account_id"
  64. t.index ["target_account_id"], name: "index_account_moderation_notes_on_target_account_id"
  65. end
  66. create_table "account_notes", force: :cascade do |t|
  67. t.bigint "account_id"
  68. t.bigint "target_account_id"
  69. t.text "comment", null: false
  70. t.datetime "created_at", null: false
  71. t.datetime "updated_at", null: false
  72. t.index ["account_id", "target_account_id"], name: "index_account_notes_on_account_id_and_target_account_id", unique: true
  73. t.index ["target_account_id"], name: "index_account_notes_on_target_account_id"
  74. end
  75. create_table "account_pins", force: :cascade do |t|
  76. t.bigint "account_id"
  77. t.bigint "target_account_id"
  78. t.datetime "created_at", null: false
  79. t.datetime "updated_at", null: false
  80. t.index ["account_id", "target_account_id"], name: "index_account_pins_on_account_id_and_target_account_id", unique: true
  81. t.index ["target_account_id"], name: "index_account_pins_on_target_account_id"
  82. end
  83. create_table "account_stats", force: :cascade do |t|
  84. t.bigint "account_id", null: false
  85. t.bigint "statuses_count", default: 0, null: false
  86. t.bigint "following_count", default: 0, null: false
  87. t.bigint "followers_count", default: 0, null: false
  88. t.datetime "created_at", null: false
  89. t.datetime "updated_at", null: false
  90. t.datetime "last_status_at"
  91. t.index ["account_id"], name: "index_account_stats_on_account_id", unique: true
  92. end
  93. create_table "account_statuses_cleanup_policies", force: :cascade do |t|
  94. t.bigint "account_id", null: false
  95. t.boolean "enabled", default: true, null: false
  96. t.integer "min_status_age", default: 1209600, null: false
  97. t.boolean "keep_direct", default: true, null: false
  98. t.boolean "keep_pinned", default: true, null: false
  99. t.boolean "keep_polls", default: false, null: false
  100. t.boolean "keep_media", default: false, null: false
  101. t.boolean "keep_self_fav", default: true, null: false
  102. t.boolean "keep_self_bookmark", default: true, null: false
  103. t.integer "min_favs"
  104. t.integer "min_reblogs"
  105. t.datetime "created_at", precision: 6, null: false
  106. t.datetime "updated_at", precision: 6, null: false
  107. t.boolean "keep_local", default: true, null: false
  108. t.index ["account_id"], name: "index_account_statuses_cleanup_policies_on_account_id"
  109. end
  110. create_table "account_warning_presets", force: :cascade do |t|
  111. t.text "text", default: "", null: false
  112. t.datetime "created_at", null: false
  113. t.datetime "updated_at", null: false
  114. t.string "title", default: "", null: false
  115. end
  116. create_table "account_warnings", force: :cascade do |t|
  117. t.bigint "account_id"
  118. t.bigint "target_account_id"
  119. t.integer "action", default: 0, null: false
  120. t.text "text", default: "", null: false
  121. t.datetime "created_at", null: false
  122. t.datetime "updated_at", null: false
  123. t.bigint "report_id"
  124. t.string "status_ids", array: true
  125. t.datetime "overruled_at"
  126. t.index ["account_id"], name: "index_account_warnings_on_account_id"
  127. t.index ["target_account_id"], name: "index_account_warnings_on_target_account_id"
  128. end
  129. create_table "accounts", id: :bigint, default: -> { "timestamp_id('accounts'::text)" }, force: :cascade do |t|
  130. t.string "username", default: "", null: false
  131. t.string "domain"
  132. t.text "private_key"
  133. t.text "public_key", default: "", null: false
  134. t.datetime "created_at", null: false
  135. t.datetime "updated_at", null: false
  136. t.text "note", default: "", null: false
  137. t.string "display_name", default: "", null: false
  138. t.string "uri", default: "", null: false
  139. t.string "url"
  140. t.string "avatar_file_name"
  141. t.string "avatar_content_type"
  142. t.integer "avatar_file_size"
  143. t.datetime "avatar_updated_at"
  144. t.string "header_file_name"
  145. t.string "header_content_type"
  146. t.integer "header_file_size"
  147. t.datetime "header_updated_at"
  148. t.string "avatar_remote_url"
  149. t.boolean "locked", default: false, null: false
  150. t.string "header_remote_url", default: "", null: false
  151. t.datetime "last_webfingered_at"
  152. t.string "inbox_url", default: "", null: false
  153. t.string "outbox_url", default: "", null: false
  154. t.string "shared_inbox_url", default: "", null: false
  155. t.string "followers_url", default: "", null: false
  156. t.integer "protocol", default: 0, null: false
  157. t.boolean "memorial", default: false, null: false
  158. t.bigint "moved_to_account_id"
  159. t.string "featured_collection_url"
  160. t.jsonb "fields"
  161. t.string "actor_type"
  162. t.boolean "discoverable"
  163. t.string "also_known_as", array: true
  164. t.datetime "silenced_at"
  165. t.datetime "suspended_at"
  166. t.boolean "hide_collections"
  167. t.integer "avatar_storage_schema_version"
  168. t.integer "header_storage_schema_version"
  169. t.string "devices_url"
  170. t.integer "suspension_origin"
  171. t.datetime "sensitized_at"
  172. t.boolean "trendable"
  173. t.datetime "reviewed_at"
  174. t.datetime "requested_review_at"
  175. t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin
  176. t.index "lower((username)::text), COALESCE(lower((domain)::text), ''::text)", name: "index_accounts_on_username_and_domain_lower", unique: true
  177. t.index ["moved_to_account_id"], name: "index_accounts_on_moved_to_account_id", where: "(moved_to_account_id IS NOT NULL)"
  178. t.index ["uri"], name: "index_accounts_on_uri"
  179. t.index ["url"], name: "index_accounts_on_url", opclass: :text_pattern_ops, where: "(url IS NOT NULL)"
  180. end
  181. create_table "accounts_tags", id: false, force: :cascade do |t|
  182. t.bigint "account_id", null: false
  183. t.bigint "tag_id", null: false
  184. t.index ["account_id", "tag_id"], name: "index_accounts_tags_on_account_id_and_tag_id"
  185. t.index ["tag_id", "account_id"], name: "index_accounts_tags_on_tag_id_and_account_id", unique: true
  186. end
  187. create_table "admin_action_logs", force: :cascade do |t|
  188. t.bigint "account_id"
  189. t.string "action", default: "", null: false
  190. t.string "target_type"
  191. t.bigint "target_id"
  192. t.datetime "created_at", null: false
  193. t.datetime "updated_at", null: false
  194. t.string "human_identifier"
  195. t.string "route_param"
  196. t.string "permalink"
  197. t.index ["account_id"], name: "index_admin_action_logs_on_account_id"
  198. t.index ["target_type", "target_id"], name: "index_admin_action_logs_on_target_type_and_target_id"
  199. end
  200. create_table "announcement_mutes", force: :cascade do |t|
  201. t.bigint "account_id"
  202. t.bigint "announcement_id"
  203. t.datetime "created_at", null: false
  204. t.datetime "updated_at", null: false
  205. t.index ["account_id", "announcement_id"], name: "index_announcement_mutes_on_account_id_and_announcement_id", unique: true
  206. t.index ["announcement_id"], name: "index_announcement_mutes_on_announcement_id"
  207. end
  208. create_table "announcement_reactions", force: :cascade do |t|
  209. t.bigint "account_id"
  210. t.bigint "announcement_id"
  211. t.string "name", default: "", null: false
  212. t.bigint "custom_emoji_id"
  213. t.datetime "created_at", null: false
  214. t.datetime "updated_at", null: false
  215. t.index ["account_id", "announcement_id", "name"], name: "index_announcement_reactions_on_account_id_and_announcement_id", unique: true
  216. t.index ["announcement_id"], name: "index_announcement_reactions_on_announcement_id"
  217. t.index ["custom_emoji_id"], name: "index_announcement_reactions_on_custom_emoji_id", where: "(custom_emoji_id IS NOT NULL)"
  218. end
  219. create_table "announcements", force: :cascade do |t|
  220. t.text "text", default: "", null: false
  221. t.boolean "published", default: false, null: false
  222. t.boolean "all_day", default: false, null: false
  223. t.datetime "scheduled_at"
  224. t.datetime "starts_at"
  225. t.datetime "ends_at"
  226. t.datetime "created_at", null: false
  227. t.datetime "updated_at", null: false
  228. t.datetime "published_at"
  229. t.bigint "status_ids", array: true
  230. end
  231. create_table "appeals", force: :cascade do |t|
  232. t.bigint "account_id", null: false
  233. t.bigint "account_warning_id", null: false
  234. t.text "text", default: "", null: false
  235. t.datetime "approved_at"
  236. t.bigint "approved_by_account_id"
  237. t.datetime "rejected_at"
  238. t.bigint "rejected_by_account_id"
  239. t.datetime "created_at", precision: 6, null: false
  240. t.datetime "updated_at", precision: 6, null: false
  241. t.index ["account_id"], name: "index_appeals_on_account_id"
  242. t.index ["account_warning_id"], name: "index_appeals_on_account_warning_id", unique: true
  243. t.index ["approved_by_account_id"], name: "index_appeals_on_approved_by_account_id", where: "(approved_by_account_id IS NOT NULL)"
  244. t.index ["rejected_by_account_id"], name: "index_appeals_on_rejected_by_account_id", where: "(rejected_by_account_id IS NOT NULL)"
  245. end
  246. create_table "backups", force: :cascade do |t|
  247. t.bigint "user_id"
  248. t.string "dump_file_name"
  249. t.string "dump_content_type"
  250. t.datetime "dump_updated_at"
  251. t.boolean "processed", default: false, null: false
  252. t.datetime "created_at", null: false
  253. t.datetime "updated_at", null: false
  254. t.bigint "dump_file_size"
  255. end
  256. create_table "blocks", force: :cascade do |t|
  257. t.datetime "created_at", null: false
  258. t.datetime "updated_at", null: false
  259. t.bigint "account_id", null: false
  260. t.bigint "target_account_id", null: false
  261. t.string "uri"
  262. t.index ["account_id", "target_account_id"], name: "index_blocks_on_account_id_and_target_account_id", unique: true
  263. t.index ["target_account_id"], name: "index_blocks_on_target_account_id"
  264. end
  265. create_table "bookmarks", force: :cascade do |t|
  266. t.bigint "account_id", null: false
  267. t.bigint "status_id", null: false
  268. t.datetime "created_at", null: false
  269. t.datetime "updated_at", null: false
  270. t.index ["account_id", "status_id"], name: "index_bookmarks_on_account_id_and_status_id", unique: true
  271. t.index ["status_id"], name: "index_bookmarks_on_status_id"
  272. end
  273. create_table "canonical_email_blocks", force: :cascade do |t|
  274. t.string "canonical_email_hash", default: "", null: false
  275. t.bigint "reference_account_id"
  276. t.datetime "created_at", precision: 6, null: false
  277. t.datetime "updated_at", precision: 6, null: false
  278. t.index ["canonical_email_hash"], name: "index_canonical_email_blocks_on_canonical_email_hash", unique: true
  279. t.index ["reference_account_id"], name: "index_canonical_email_blocks_on_reference_account_id"
  280. end
  281. create_table "conversation_mutes", force: :cascade do |t|
  282. t.bigint "conversation_id", null: false
  283. t.bigint "account_id", null: false
  284. t.index ["account_id", "conversation_id"], name: "index_conversation_mutes_on_account_id_and_conversation_id", unique: true
  285. end
  286. create_table "conversations", force: :cascade do |t|
  287. t.string "uri"
  288. t.datetime "created_at", null: false
  289. t.datetime "updated_at", null: false
  290. t.index ["uri"], name: "index_conversations_on_uri", unique: true, opclass: :text_pattern_ops, where: "(uri IS NOT NULL)"
  291. end
  292. create_table "custom_emoji_categories", force: :cascade do |t|
  293. t.string "name"
  294. t.datetime "created_at", null: false
  295. t.datetime "updated_at", null: false
  296. t.index ["name"], name: "index_custom_emoji_categories_on_name", unique: true
  297. end
  298. create_table "custom_emojis", force: :cascade do |t|
  299. t.string "shortcode", default: "", null: false
  300. t.string "domain"
  301. t.string "image_file_name"
  302. t.string "image_content_type"
  303. t.integer "image_file_size"
  304. t.datetime "image_updated_at"
  305. t.datetime "created_at", null: false
  306. t.datetime "updated_at", null: false
  307. t.boolean "disabled", default: false, null: false
  308. t.string "uri"
  309. t.string "image_remote_url"
  310. t.boolean "visible_in_picker", default: true, null: false
  311. t.bigint "category_id"
  312. t.integer "image_storage_schema_version"
  313. t.index ["shortcode", "domain"], name: "index_custom_emojis_on_shortcode_and_domain", unique: true
  314. end
  315. create_table "custom_filter_keywords", force: :cascade do |t|
  316. t.bigint "custom_filter_id", null: false
  317. t.text "keyword", default: "", null: false
  318. t.boolean "whole_word", default: true, null: false
  319. t.datetime "created_at", precision: 6, null: false
  320. t.datetime "updated_at", precision: 6, null: false
  321. t.index ["custom_filter_id"], name: "index_custom_filter_keywords_on_custom_filter_id"
  322. end
  323. create_table "custom_filter_statuses", force: :cascade do |t|
  324. t.bigint "custom_filter_id", null: false
  325. t.bigint "status_id", null: false
  326. t.datetime "created_at", precision: 6, null: false
  327. t.datetime "updated_at", precision: 6, null: false
  328. t.index ["custom_filter_id"], name: "index_custom_filter_statuses_on_custom_filter_id"
  329. t.index ["status_id"], name: "index_custom_filter_statuses_on_status_id"
  330. end
  331. create_table "custom_filters", force: :cascade do |t|
  332. t.bigint "account_id"
  333. t.datetime "expires_at"
  334. t.text "phrase", default: "", null: false
  335. t.string "context", default: [], null: false, array: true
  336. t.datetime "created_at", null: false
  337. t.datetime "updated_at", null: false
  338. t.integer "action", default: 0, null: false
  339. t.index ["account_id"], name: "index_custom_filters_on_account_id"
  340. end
  341. create_table "devices", force: :cascade do |t|
  342. t.bigint "access_token_id"
  343. t.bigint "account_id"
  344. t.string "device_id", default: "", null: false
  345. t.string "name", default: "", null: false
  346. t.text "fingerprint_key", default: "", null: false
  347. t.text "identity_key", default: "", null: false
  348. t.datetime "created_at", null: false
  349. t.datetime "updated_at", null: false
  350. t.index ["access_token_id"], name: "index_devices_on_access_token_id"
  351. t.index ["account_id"], name: "index_devices_on_account_id"
  352. end
  353. create_table "domain_allows", force: :cascade do |t|
  354. t.string "domain", default: "", null: false
  355. t.datetime "created_at", null: false
  356. t.datetime "updated_at", null: false
  357. t.index ["domain"], name: "index_domain_allows_on_domain", unique: true
  358. end
  359. create_table "domain_blocks", force: :cascade do |t|
  360. t.string "domain", default: "", null: false
  361. t.datetime "created_at", null: false
  362. t.datetime "updated_at", null: false
  363. t.integer "severity", default: 0
  364. t.boolean "reject_media", default: false, null: false
  365. t.boolean "reject_reports", default: false, null: false
  366. t.text "private_comment"
  367. t.text "public_comment"
  368. t.boolean "obfuscate", default: false, null: false
  369. t.index ["domain"], name: "index_domain_blocks_on_domain", unique: true
  370. end
  371. create_table "email_domain_blocks", force: :cascade do |t|
  372. t.string "domain", default: "", null: false
  373. t.datetime "created_at", null: false
  374. t.datetime "updated_at", null: false
  375. t.bigint "parent_id"
  376. t.index ["domain"], name: "index_email_domain_blocks_on_domain", unique: true
  377. end
  378. create_table "encrypted_messages", id: :bigint, default: -> { "timestamp_id('encrypted_messages'::text)" }, force: :cascade do |t|
  379. t.bigint "device_id"
  380. t.bigint "from_account_id"
  381. t.string "from_device_id", default: "", null: false
  382. t.integer "type", default: 0, null: false
  383. t.text "body", default: "", null: false
  384. t.text "digest", default: "", null: false
  385. t.text "message_franking", default: "", null: false
  386. t.datetime "created_at", null: false
  387. t.datetime "updated_at", null: false
  388. t.index ["device_id"], name: "index_encrypted_messages_on_device_id"
  389. t.index ["from_account_id"], name: "index_encrypted_messages_on_from_account_id"
  390. end
  391. create_table "favourites", force: :cascade do |t|
  392. t.datetime "created_at", null: false
  393. t.datetime "updated_at", null: false
  394. t.bigint "account_id", null: false
  395. t.bigint "status_id", null: false
  396. t.index ["account_id", "id"], name: "index_favourites_on_account_id_and_id"
  397. t.index ["account_id", "status_id"], name: "index_favourites_on_account_id_and_status_id", unique: true
  398. t.index ["status_id"], name: "index_favourites_on_status_id"
  399. end
  400. create_table "featured_tags", force: :cascade do |t|
  401. t.bigint "account_id", null: false
  402. t.bigint "tag_id", null: false
  403. t.bigint "statuses_count", default: 0, null: false
  404. t.datetime "last_status_at"
  405. t.datetime "created_at", null: false
  406. t.datetime "updated_at", null: false
  407. t.string "name"
  408. t.index ["account_id", "tag_id"], name: "index_featured_tags_on_account_id_and_tag_id", unique: true
  409. t.index ["tag_id"], name: "index_featured_tags_on_tag_id"
  410. end
  411. create_table "follow_recommendation_suppressions", force: :cascade do |t|
  412. t.bigint "account_id", null: false
  413. t.datetime "created_at", precision: 6, null: false
  414. t.datetime "updated_at", precision: 6, null: false
  415. t.index ["account_id"], name: "index_follow_recommendation_suppressions_on_account_id", unique: true
  416. end
  417. create_table "follow_requests", force: :cascade do |t|
  418. t.datetime "created_at", null: false
  419. t.datetime "updated_at", null: false
  420. t.bigint "account_id", null: false
  421. t.bigint "target_account_id", null: false
  422. t.boolean "show_reblogs", default: true, null: false
  423. t.string "uri"
  424. t.boolean "notify", default: false, null: false
  425. t.string "languages", array: true
  426. t.index ["account_id", "target_account_id"], name: "index_follow_requests_on_account_id_and_target_account_id", unique: true
  427. end
  428. create_table "follows", force: :cascade do |t|
  429. t.datetime "created_at", null: false
  430. t.datetime "updated_at", null: false
  431. t.bigint "account_id", null: false
  432. t.bigint "target_account_id", null: false
  433. t.boolean "show_reblogs", default: true, null: false
  434. t.string "uri"
  435. t.boolean "notify", default: false, null: false
  436. t.string "languages", array: true
  437. t.index ["account_id", "target_account_id"], name: "index_follows_on_account_id_and_target_account_id", unique: true
  438. t.index ["target_account_id"], name: "index_follows_on_target_account_id"
  439. end
  440. create_table "identities", force: :cascade do |t|
  441. t.string "provider", default: "", null: false
  442. t.string "uid", default: "", null: false
  443. t.datetime "created_at", null: false
  444. t.datetime "updated_at", null: false
  445. t.bigint "user_id"
  446. t.index ["user_id"], name: "index_identities_on_user_id"
  447. end
  448. create_table "imports", force: :cascade do |t|
  449. t.integer "type", null: false
  450. t.boolean "approved", default: false, null: false
  451. t.datetime "created_at", null: false
  452. t.datetime "updated_at", null: false
  453. t.string "data_file_name"
  454. t.string "data_content_type"
  455. t.integer "data_file_size"
  456. t.datetime "data_updated_at"
  457. t.bigint "account_id", null: false
  458. t.boolean "overwrite", default: false, null: false
  459. end
  460. create_table "invites", force: :cascade do |t|
  461. t.bigint "user_id", null: false
  462. t.string "code", default: "", null: false
  463. t.datetime "expires_at"
  464. t.integer "max_uses"
  465. t.integer "uses", default: 0, null: false
  466. t.datetime "created_at", null: false
  467. t.datetime "updated_at", null: false
  468. t.boolean "autofollow", default: false, null: false
  469. t.text "comment"
  470. t.index ["code"], name: "index_invites_on_code", unique: true
  471. t.index ["user_id"], name: "index_invites_on_user_id"
  472. end
  473. create_table "ip_blocks", force: :cascade do |t|
  474. t.datetime "created_at", null: false
  475. t.datetime "updated_at", null: false
  476. t.datetime "expires_at"
  477. t.inet "ip", default: "0.0.0.0", null: false
  478. t.integer "severity", default: 0, null: false
  479. t.text "comment", default: "", null: false
  480. t.index ["ip"], name: "index_ip_blocks_on_ip", unique: true
  481. end
  482. create_table "list_accounts", force: :cascade do |t|
  483. t.bigint "list_id", null: false
  484. t.bigint "account_id", null: false
  485. t.bigint "follow_id"
  486. t.index ["account_id", "list_id"], name: "index_list_accounts_on_account_id_and_list_id", unique: true
  487. t.index ["follow_id"], name: "index_list_accounts_on_follow_id", where: "(follow_id IS NOT NULL)"
  488. t.index ["list_id", "account_id"], name: "index_list_accounts_on_list_id_and_account_id"
  489. end
  490. create_table "lists", force: :cascade do |t|
  491. t.bigint "account_id", null: false
  492. t.string "title", default: "", null: false
  493. t.datetime "created_at", null: false
  494. t.datetime "updated_at", null: false
  495. t.integer "replies_policy", default: 0, null: false
  496. t.boolean "is_exclusive", default: false
  497. t.index ["account_id"], name: "index_lists_on_account_id"
  498. end
  499. create_table "login_activities", force: :cascade do |t|
  500. t.bigint "user_id", null: false
  501. t.string "authentication_method"
  502. t.string "provider"
  503. t.boolean "success"
  504. t.string "failure_reason"
  505. t.inet "ip"
  506. t.string "user_agent"
  507. t.datetime "created_at"
  508. t.index ["user_id"], name: "index_login_activities_on_user_id"
  509. end
  510. create_table "markers", force: :cascade do |t|
  511. t.bigint "user_id"
  512. t.string "timeline", default: "", null: false
  513. t.bigint "last_read_id", default: 0, null: false
  514. t.integer "lock_version", default: 0, null: false
  515. t.datetime "created_at", null: false
  516. t.datetime "updated_at", null: false
  517. t.index ["user_id", "timeline"], name: "index_markers_on_user_id_and_timeline", unique: true
  518. end
  519. create_table "media_attachments", id: :bigint, default: -> { "timestamp_id('media_attachments'::text)" }, force: :cascade do |t|
  520. t.bigint "status_id"
  521. t.string "file_file_name"
  522. t.string "file_content_type"
  523. t.integer "file_file_size"
  524. t.datetime "file_updated_at"
  525. t.string "remote_url", default: "", null: false
  526. t.datetime "created_at", null: false
  527. t.datetime "updated_at", null: false
  528. t.string "shortcode"
  529. t.integer "type", default: 0, null: false
  530. t.json "file_meta"
  531. t.bigint "account_id"
  532. t.text "description"
  533. t.bigint "scheduled_status_id"
  534. t.string "blurhash"
  535. t.integer "processing"
  536. t.integer "file_storage_schema_version"
  537. t.string "thumbnail_file_name"
  538. t.string "thumbnail_content_type"
  539. t.integer "thumbnail_file_size"
  540. t.datetime "thumbnail_updated_at"
  541. t.string "thumbnail_remote_url"
  542. t.index ["account_id", "status_id"], name: "index_media_attachments_on_account_id_and_status_id", order: { status_id: :desc }
  543. t.index ["scheduled_status_id"], name: "index_media_attachments_on_scheduled_status_id", where: "(scheduled_status_id IS NOT NULL)"
  544. t.index ["shortcode"], name: "index_media_attachments_on_shortcode", unique: true, opclass: :text_pattern_ops, where: "(shortcode IS NOT NULL)"
  545. t.index ["status_id"], name: "index_media_attachments_on_status_id"
  546. end
  547. create_table "mentions", force: :cascade do |t|
  548. t.bigint "status_id"
  549. t.datetime "created_at", null: false
  550. t.datetime "updated_at", null: false
  551. t.bigint "account_id"
  552. t.boolean "silent", default: false, null: false
  553. t.index ["account_id", "status_id"], name: "index_mentions_on_account_id_and_status_id", unique: true
  554. t.index ["status_id"], name: "index_mentions_on_status_id"
  555. end
  556. create_table "mutes", force: :cascade do |t|
  557. t.datetime "created_at", null: false
  558. t.datetime "updated_at", null: false
  559. t.boolean "hide_notifications", default: true, null: false
  560. t.bigint "account_id", null: false
  561. t.bigint "target_account_id", null: false
  562. t.datetime "expires_at"
  563. t.index ["account_id", "target_account_id"], name: "index_mutes_on_account_id_and_target_account_id", unique: true
  564. t.index ["target_account_id"], name: "index_mutes_on_target_account_id"
  565. end
  566. create_table "notifications", force: :cascade do |t|
  567. t.bigint "activity_id", null: false
  568. t.string "activity_type", null: false
  569. t.datetime "created_at", null: false
  570. t.datetime "updated_at", null: false
  571. t.bigint "account_id", null: false
  572. t.bigint "from_account_id", null: false
  573. t.string "type"
  574. t.index ["account_id", "id", "type"], name: "index_notifications_on_account_id_and_id_and_type", order: { id: :desc }
  575. t.index ["activity_id", "activity_type"], name: "index_notifications_on_activity_id_and_activity_type"
  576. t.index ["from_account_id"], name: "index_notifications_on_from_account_id"
  577. end
  578. create_table "oauth_access_grants", force: :cascade do |t|
  579. t.string "token", null: false
  580. t.integer "expires_in", null: false
  581. t.text "redirect_uri", null: false
  582. t.datetime "created_at", null: false
  583. t.datetime "revoked_at"
  584. t.string "scopes"
  585. t.bigint "application_id", null: false
  586. t.bigint "resource_owner_id", null: false
  587. t.index ["resource_owner_id"], name: "index_oauth_access_grants_on_resource_owner_id"
  588. t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true
  589. end
  590. create_table "oauth_access_tokens", force: :cascade do |t|
  591. t.string "token", null: false
  592. t.string "refresh_token"
  593. t.integer "expires_in"
  594. t.datetime "revoked_at"
  595. t.datetime "created_at", null: false
  596. t.string "scopes"
  597. t.bigint "application_id"
  598. t.bigint "resource_owner_id"
  599. t.datetime "last_used_at"
  600. t.inet "last_used_ip"
  601. t.index ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true, opclass: :text_pattern_ops, where: "(refresh_token IS NOT NULL)"
  602. t.index ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id", where: "(resource_owner_id IS NOT NULL)"
  603. t.index ["token"], name: "index_oauth_access_tokens_on_token", unique: true
  604. end
  605. create_table "oauth_applications", force: :cascade do |t|
  606. t.string "name", null: false
  607. t.string "uid", null: false
  608. t.string "secret", null: false
  609. t.text "redirect_uri", null: false
  610. t.string "scopes", default: "", null: false
  611. t.datetime "created_at"
  612. t.datetime "updated_at"
  613. t.boolean "superapp", default: false, null: false
  614. t.string "website"
  615. t.string "owner_type"
  616. t.bigint "owner_id"
  617. t.boolean "confidential", default: true, null: false
  618. t.index ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type"
  619. t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true
  620. end
  621. create_table "one_time_keys", force: :cascade do |t|
  622. t.bigint "device_id"
  623. t.string "key_id", default: "", null: false
  624. t.text "key", default: "", null: false
  625. t.text "signature", default: "", null: false
  626. t.datetime "created_at", null: false
  627. t.datetime "updated_at", null: false
  628. t.index ["device_id"], name: "index_one_time_keys_on_device_id"
  629. t.index ["key_id"], name: "index_one_time_keys_on_key_id"
  630. end
  631. create_table "pghero_space_stats", force: :cascade do |t|
  632. t.text "database"
  633. t.text "schema"
  634. t.text "relation"
  635. t.bigint "size"
  636. t.datetime "captured_at"
  637. t.index ["database", "captured_at"], name: "index_pghero_space_stats_on_database_and_captured_at"
  638. end
  639. create_table "poll_votes", force: :cascade do |t|
  640. t.bigint "account_id"
  641. t.bigint "poll_id"
  642. t.integer "choice", default: 0, null: false
  643. t.datetime "created_at", null: false
  644. t.datetime "updated_at", null: false
  645. t.string "uri"
  646. t.index ["account_id"], name: "index_poll_votes_on_account_id"
  647. t.index ["poll_id"], name: "index_poll_votes_on_poll_id"
  648. end
  649. create_table "polls", force: :cascade do |t|
  650. t.bigint "account_id"
  651. t.bigint "status_id"
  652. t.datetime "expires_at"
  653. t.string "options", default: [], null: false, array: true
  654. t.bigint "cached_tallies", default: [], null: false, array: true
  655. t.boolean "multiple", default: false, null: false
  656. t.boolean "hide_totals", default: false, null: false
  657. t.bigint "votes_count", default: 0, null: false
  658. t.datetime "last_fetched_at"
  659. t.datetime "created_at", null: false
  660. t.datetime "updated_at", null: false
  661. t.integer "lock_version", default: 0, null: false
  662. t.bigint "voters_count"
  663. t.index ["account_id"], name: "index_polls_on_account_id"
  664. t.index ["status_id"], name: "index_polls_on_status_id"
  665. end
  666. create_table "preview_card_providers", force: :cascade do |t|
  667. t.string "domain", default: "", null: false
  668. t.string "icon_file_name"
  669. t.string "icon_content_type"
  670. t.bigint "icon_file_size"
  671. t.datetime "icon_updated_at"
  672. t.boolean "trendable"
  673. t.datetime "reviewed_at"
  674. t.datetime "requested_review_at"
  675. t.datetime "created_at", precision: 6, null: false
  676. t.datetime "updated_at", precision: 6, null: false
  677. t.index ["domain"], name: "index_preview_card_providers_on_domain", unique: true
  678. end
  679. create_table "preview_card_trends", force: :cascade do |t|
  680. t.bigint "preview_card_id", null: false
  681. t.float "score", default: 0.0, null: false
  682. t.integer "rank", default: 0, null: false
  683. t.boolean "allowed", default: false, null: false
  684. t.string "language"
  685. t.index ["preview_card_id"], name: "index_preview_card_trends_on_preview_card_id", unique: true
  686. end
  687. create_table "preview_cards", force: :cascade do |t|
  688. t.string "url", default: "", null: false
  689. t.string "title", default: "", null: false
  690. t.string "description", default: "", null: false
  691. t.string "image_file_name"
  692. t.string "image_content_type"
  693. t.integer "image_file_size"
  694. t.datetime "image_updated_at"
  695. t.integer "type", default: 0, null: false
  696. t.text "html", default: "", null: false
  697. t.string "author_name", default: "", null: false
  698. t.string "author_url", default: "", null: false
  699. t.string "provider_name", default: "", null: false
  700. t.string "provider_url", default: "", null: false
  701. t.integer "width", default: 0, null: false
  702. t.integer "height", default: 0, null: false
  703. t.datetime "created_at", null: false
  704. t.datetime "updated_at", null: false
  705. t.string "embed_url", default: "", null: false
  706. t.integer "image_storage_schema_version"
  707. t.string "blurhash"
  708. t.string "language"
  709. t.float "max_score"
  710. t.datetime "max_score_at"
  711. t.boolean "trendable"
  712. t.integer "link_type"
  713. t.index ["url"], name: "index_preview_cards_on_url", unique: true
  714. end
  715. create_table "preview_cards_statuses", id: false, force: :cascade do |t|
  716. t.bigint "preview_card_id", null: false
  717. t.bigint "status_id", null: false
  718. t.index ["status_id", "preview_card_id"], name: "index_preview_cards_statuses_on_status_id_and_preview_card_id"
  719. end
  720. create_table "relays", force: :cascade do |t|
  721. t.string "inbox_url", default: "", null: false
  722. t.string "follow_activity_id"
  723. t.datetime "created_at", null: false
  724. t.datetime "updated_at", null: false
  725. t.integer "state", default: 0, null: false
  726. end
  727. create_table "report_notes", force: :cascade do |t|
  728. t.text "content", null: false
  729. t.bigint "report_id", null: false
  730. t.bigint "account_id", null: false
  731. t.datetime "created_at", null: false
  732. t.datetime "updated_at", null: false
  733. t.index ["account_id"], name: "index_report_notes_on_account_id"
  734. t.index ["report_id"], name: "index_report_notes_on_report_id"
  735. end
  736. create_table "reports", force: :cascade do |t|
  737. t.bigint "status_ids", default: [], null: false, array: true
  738. t.text "comment", default: "", null: false
  739. t.datetime "created_at", null: false
  740. t.datetime "updated_at", null: false
  741. t.bigint "account_id", null: false
  742. t.bigint "action_taken_by_account_id"
  743. t.bigint "target_account_id", null: false
  744. t.bigint "assigned_account_id"
  745. t.string "uri"
  746. t.boolean "forwarded"
  747. t.integer "category", default: 0, null: false
  748. t.datetime "action_taken_at"
  749. t.bigint "rule_ids", array: true
  750. t.index ["account_id"], name: "index_reports_on_account_id"
  751. t.index ["action_taken_by_account_id"], name: "index_reports_on_action_taken_by_account_id", where: "(action_taken_by_account_id IS NOT NULL)"
  752. t.index ["assigned_account_id"], name: "index_reports_on_assigned_account_id", where: "(assigned_account_id IS NOT NULL)"
  753. t.index ["target_account_id"], name: "index_reports_on_target_account_id"
  754. end
  755. create_table "rules", force: :cascade do |t|
  756. t.integer "priority", default: 0, null: false
  757. t.datetime "deleted_at"
  758. t.text "text", default: "", null: false
  759. t.datetime "created_at", null: false
  760. t.datetime "updated_at", null: false
  761. end
  762. create_table "scheduled_statuses", force: :cascade do |t|
  763. t.bigint "account_id"
  764. t.datetime "scheduled_at"
  765. t.jsonb "params"
  766. t.index ["account_id"], name: "index_scheduled_statuses_on_account_id"
  767. t.index ["scheduled_at"], name: "index_scheduled_statuses_on_scheduled_at"
  768. end
  769. create_table "session_activations", force: :cascade do |t|
  770. t.string "session_id", null: false
  771. t.datetime "created_at", null: false
  772. t.datetime "updated_at", null: false
  773. t.string "user_agent", default: "", null: false
  774. t.inet "ip"
  775. t.bigint "access_token_id"
  776. t.bigint "user_id", null: false
  777. t.bigint "web_push_subscription_id"
  778. t.index ["access_token_id"], name: "index_session_activations_on_access_token_id"
  779. t.index ["session_id"], name: "index_session_activations_on_session_id", unique: true
  780. t.index ["user_id"], name: "index_session_activations_on_user_id"
  781. end
  782. create_table "settings", force: :cascade do |t|
  783. t.string "var", null: false
  784. t.text "value"
  785. t.string "thing_type"
  786. t.datetime "created_at"
  787. t.datetime "updated_at"
  788. t.bigint "thing_id"
  789. t.index ["thing_type", "thing_id", "var"], name: "index_settings_on_thing_type_and_thing_id_and_var", unique: true
  790. end
  791. create_table "site_uploads", force: :cascade do |t|
  792. t.string "var", default: "", null: false
  793. t.string "file_file_name"
  794. t.string "file_content_type"
  795. t.integer "file_file_size"
  796. t.datetime "file_updated_at"
  797. t.json "meta"
  798. t.datetime "created_at", null: false
  799. t.datetime "updated_at", null: false
  800. t.string "blurhash"
  801. t.index ["var"], name: "index_site_uploads_on_var", unique: true
  802. end
  803. create_table "status_edits", force: :cascade do |t|
  804. t.bigint "status_id", null: false
  805. t.bigint "account_id"
  806. t.text "text", default: "", null: false
  807. t.text "spoiler_text", default: "", null: false
  808. t.datetime "created_at", precision: 6, null: false
  809. t.datetime "updated_at", precision: 6, null: false
  810. t.bigint "ordered_media_attachment_ids", array: true
  811. t.text "media_descriptions", array: true
  812. t.string "poll_options", array: true
  813. t.boolean "sensitive"
  814. t.index ["account_id"], name: "index_status_edits_on_account_id"
  815. t.index ["status_id"], name: "index_status_edits_on_status_id"
  816. end
  817. create_table "status_pins", force: :cascade do |t|
  818. t.bigint "account_id", null: false
  819. t.bigint "status_id", null: false
  820. t.datetime "created_at", default: -> { "now()" }, null: false
  821. t.datetime "updated_at", default: -> { "now()" }, null: false
  822. t.index ["account_id", "status_id"], name: "index_status_pins_on_account_id_and_status_id", unique: true
  823. t.index ["status_id"], name: "index_status_pins_on_status_id"
  824. end
  825. create_table "status_stats", force: :cascade do |t|
  826. t.bigint "status_id", null: false
  827. t.bigint "replies_count", default: 0, null: false
  828. t.bigint "reblogs_count", default: 0, null: false
  829. t.bigint "favourites_count", default: 0, null: false
  830. t.datetime "created_at", null: false
  831. t.datetime "updated_at", null: false
  832. t.index ["status_id"], name: "index_status_stats_on_status_id", unique: true
  833. end
  834. create_table "status_trends", force: :cascade do |t|
  835. t.bigint "status_id", null: false
  836. t.bigint "account_id", null: false
  837. t.float "score", default: 0.0, null: false
  838. t.integer "rank", default: 0, null: false
  839. t.boolean "allowed", default: false, null: false
  840. t.string "language"
  841. t.index ["account_id"], name: "index_status_trends_on_account_id"
  842. t.index ["status_id"], name: "index_status_trends_on_status_id", unique: true
  843. end
  844. create_table "statuses", id: :bigint, default: -> { "timestamp_id('statuses'::text)" }, force: :cascade do |t|
  845. t.string "uri"
  846. t.text "text", default: "", null: false
  847. t.datetime "created_at", null: false
  848. t.datetime "updated_at", null: false
  849. t.bigint "in_reply_to_id"
  850. t.bigint "reblog_of_id"
  851. t.string "url"
  852. t.boolean "sensitive", default: false, null: false
  853. t.integer "visibility", default: 0, null: false
  854. t.text "spoiler_text", default: "", null: false
  855. t.boolean "reply", default: false, null: false
  856. t.string "language"
  857. t.bigint "conversation_id"
  858. t.boolean "local"
  859. t.bigint "account_id", null: false
  860. t.bigint "application_id"
  861. t.bigint "in_reply_to_account_id"
  862. t.bigint "poll_id"
  863. t.datetime "deleted_at"
  864. t.boolean "local_only"
  865. t.string "activity_pub_type"
  866. t.datetime "edited_at"
  867. t.boolean "trendable"
  868. t.bigint "ordered_media_attachment_ids", array: true
  869. t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20190820", order: { id: :desc }, where: "(deleted_at IS NULL)"
  870. t.index ["account_id"], name: "index_statuses_on_account_id"
  871. t.index ["deleted_at"], name: "index_statuses_on_deleted_at", where: "(deleted_at IS NOT NULL)"
  872. t.index ["id", "account_id"], name: "index_statuses_local_20190824", order: { id: :desc }, where: "((local OR (uri IS NULL)) AND (deleted_at IS NULL) AND (visibility = 0) AND (reblog_of_id IS NULL) AND ((NOT reply) OR (in_reply_to_account_id = account_id)))"
  873. t.index ["id", "account_id"], name: "index_statuses_public_20200119", order: { id: :desc }, where: "((deleted_at IS NULL) AND (visibility = 0) AND (reblog_of_id IS NULL) AND ((NOT reply) OR (in_reply_to_account_id = account_id)))"
  874. t.index ["in_reply_to_account_id"], name: "index_statuses_on_in_reply_to_account_id", where: "(in_reply_to_account_id IS NOT NULL)"
  875. t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id", where: "(in_reply_to_id IS NOT NULL)"
  876. t.index ["reblog_of_id", "account_id"], name: "index_statuses_on_reblog_of_id_and_account_id"
  877. t.index ["uri"], name: "index_statuses_on_uri", unique: true, opclass: :text_pattern_ops, where: "(uri IS NOT NULL)"
  878. end
  879. create_table "statuses_tags", id: false, force: :cascade do |t|
  880. t.bigint "status_id", null: false
  881. t.bigint "tag_id", null: false
  882. t.index ["status_id"], name: "index_statuses_tags_on_status_id"
  883. t.index ["tag_id", "status_id"], name: "index_statuses_tags_on_tag_id_and_status_id", unique: true
  884. end
  885. create_table "system_keys", force: :cascade do |t|
  886. t.binary "key"
  887. t.datetime "created_at", null: false
  888. t.datetime "updated_at", null: false
  889. end
  890. create_table "tag_follows", force: :cascade do |t|
  891. t.bigint "tag_id", null: false
  892. t.bigint "account_id", null: false
  893. t.datetime "created_at", precision: 6, null: false
  894. t.datetime "updated_at", precision: 6, null: false
  895. t.index ["account_id", "tag_id"], name: "index_tag_follows_on_account_id_and_tag_id", unique: true
  896. t.index ["tag_id"], name: "index_tag_follows_on_tag_id"
  897. end
  898. create_table "tags", force: :cascade do |t|
  899. t.string "name", default: "", null: false
  900. t.datetime "created_at", null: false
  901. t.datetime "updated_at", null: false
  902. t.boolean "usable"
  903. t.boolean "trendable"
  904. t.boolean "listable"
  905. t.datetime "reviewed_at"
  906. t.datetime "requested_review_at"
  907. t.datetime "last_status_at"
  908. t.float "max_score"
  909. t.datetime "max_score_at"
  910. t.string "display_name"
  911. t.index "lower((name)::text) text_pattern_ops", name: "index_tags_on_name_lower_btree", unique: true
  912. end
  913. create_table "tombstones", force: :cascade do |t|
  914. t.bigint "account_id"
  915. t.string "uri", null: false
  916. t.datetime "created_at", null: false
  917. t.datetime "updated_at", null: false
  918. t.boolean "by_moderator"
  919. t.index ["account_id"], name: "index_tombstones_on_account_id"
  920. t.index ["uri"], name: "index_tombstones_on_uri"
  921. end
  922. create_table "unavailable_domains", force: :cascade do |t|
  923. t.string "domain", default: "", null: false
  924. t.datetime "created_at", null: false
  925. t.datetime "updated_at", null: false
  926. t.index ["domain"], name: "index_unavailable_domains_on_domain", unique: true
  927. end
  928. create_table "user_invite_requests", force: :cascade do |t|
  929. t.bigint "user_id"
  930. t.text "text"
  931. t.datetime "created_at", null: false
  932. t.datetime "updated_at", null: false
  933. t.index ["user_id"], name: "index_user_invite_requests_on_user_id"
  934. end
  935. create_table "user_roles", force: :cascade do |t|
  936. t.string "name", default: "", null: false
  937. t.string "color", default: "", null: false
  938. t.integer "position", default: 0, null: false
  939. t.bigint "permissions", default: 0, null: false
  940. t.boolean "highlighted", default: false, null: false
  941. t.datetime "created_at", precision: 6, null: false
  942. t.datetime "updated_at", precision: 6, null: false
  943. end
  944. create_table "users", force: :cascade do |t|
  945. t.string "email", default: "", null: false
  946. t.datetime "created_at", null: false
  947. t.datetime "updated_at", null: false
  948. t.string "encrypted_password", default: "", null: false
  949. t.string "reset_password_token"
  950. t.datetime "reset_password_sent_at"
  951. t.integer "sign_in_count", default: 0, null: false
  952. t.datetime "current_sign_in_at"
  953. t.datetime "last_sign_in_at"
  954. t.boolean "admin", default: false, null: false
  955. t.string "confirmation_token"
  956. t.datetime "confirmed_at"
  957. t.datetime "confirmation_sent_at"
  958. t.string "unconfirmed_email"
  959. t.string "locale"
  960. t.string "encrypted_otp_secret"
  961. t.string "encrypted_otp_secret_iv"
  962. t.string "encrypted_otp_secret_salt"
  963. t.integer "consumed_timestep"
  964. t.boolean "otp_required_for_login", default: false, null: false
  965. t.datetime "last_emailed_at"
  966. t.string "otp_backup_codes", array: true
  967. t.bigint "account_id", null: false
  968. t.boolean "disabled", default: false, null: false
  969. t.boolean "moderator", default: false, null: false
  970. t.bigint "invite_id"
  971. t.string "chosen_languages", array: true
  972. t.bigint "created_by_application_id"
  973. t.boolean "approved", default: true, null: false
  974. t.string "sign_in_token"
  975. t.datetime "sign_in_token_sent_at"
  976. t.string "webauthn_id"
  977. t.inet "sign_up_ip"
  978. t.boolean "skip_sign_in_token"
  979. t.bigint "role_id"
  980. t.index ["account_id"], name: "index_users_on_account_id"
  981. t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
  982. t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id", where: "(created_by_application_id IS NOT NULL)"
  983. t.index ["email"], name: "index_users_on_email", unique: true
  984. t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, opclass: :text_pattern_ops, where: "(reset_password_token IS NOT NULL)"
  985. t.index ["role_id"], name: "index_users_on_role_id", where: "(role_id IS NOT NULL)"
  986. end
  987. create_table "web_push_subscriptions", force: :cascade do |t|
  988. t.string "endpoint", null: false
  989. t.string "key_p256dh", null: false
  990. t.string "key_auth", null: false
  991. t.json "data"
  992. t.datetime "created_at", null: false
  993. t.datetime "updated_at", null: false
  994. t.bigint "access_token_id"
  995. t.bigint "user_id"
  996. t.index ["access_token_id"], name: "index_web_push_subscriptions_on_access_token_id", where: "(access_token_id IS NOT NULL)"
  997. t.index ["user_id"], name: "index_web_push_subscriptions_on_user_id"
  998. end
  999. create_table "web_settings", force: :cascade do |t|
  1000. t.json "data"
  1001. t.datetime "created_at", null: false
  1002. t.datetime "updated_at", null: false
  1003. t.bigint "user_id", null: false
  1004. t.index ["user_id"], name: "index_web_settings_on_user_id", unique: true
  1005. end
  1006. create_table "webauthn_credentials", force: :cascade do |t|
  1007. t.string "external_id", null: false
  1008. t.string "public_key", null: false
  1009. t.string "nickname", null: false
  1010. t.bigint "sign_count", default: 0, null: false
  1011. t.bigint "user_id"
  1012. t.datetime "created_at", null: false
  1013. t.datetime "updated_at", null: false
  1014. t.index ["external_id"], name: "index_webauthn_credentials_on_external_id", unique: true
  1015. t.index ["user_id"], name: "index_webauthn_credentials_on_user_id"
  1016. end
  1017. create_table "webhooks", force: :cascade do |t|
  1018. t.string "url", null: false
  1019. t.string "events", default: [], null: false, array: true
  1020. t.string "secret", default: "", null: false
  1021. t.boolean "enabled", default: true, null: false
  1022. t.datetime "created_at", precision: 6, null: false
  1023. t.datetime "updated_at", precision: 6, null: false
  1024. t.index ["url"], name: "index_webhooks_on_url", unique: true
  1025. end
  1026. add_foreign_key "account_aliases", "accounts", on_delete: :cascade
  1027. add_foreign_key "account_conversations", "accounts", on_delete: :cascade
  1028. add_foreign_key "account_conversations", "conversations", on_delete: :cascade
  1029. add_foreign_key "account_deletion_requests", "accounts", on_delete: :cascade
  1030. add_foreign_key "account_domain_blocks", "accounts", name: "fk_206c6029bd", on_delete: :cascade
  1031. add_foreign_key "account_migrations", "accounts", column: "target_account_id", on_delete: :nullify
  1032. add_foreign_key "account_migrations", "accounts", on_delete: :cascade
  1033. add_foreign_key "account_moderation_notes", "accounts"
  1034. add_foreign_key "account_moderation_notes", "accounts", column: "target_account_id"
  1035. add_foreign_key "account_notes", "accounts", column: "target_account_id", on_delete: :cascade
  1036. add_foreign_key "account_notes", "accounts", on_delete: :cascade
  1037. add_foreign_key "account_pins", "accounts", column: "target_account_id", on_delete: :cascade
  1038. add_foreign_key "account_pins", "accounts", on_delete: :cascade
  1039. add_foreign_key "account_stats", "accounts", on_delete: :cascade
  1040. add_foreign_key "account_statuses_cleanup_policies", "accounts", on_delete: :cascade
  1041. add_foreign_key "account_warnings", "accounts", column: "target_account_id", on_delete: :cascade
  1042. add_foreign_key "account_warnings", "accounts", on_delete: :nullify
  1043. add_foreign_key "account_warnings", "reports", on_delete: :cascade
  1044. add_foreign_key "accounts", "accounts", column: "moved_to_account_id", on_delete: :nullify
  1045. add_foreign_key "admin_action_logs", "accounts", on_delete: :cascade
  1046. add_foreign_key "announcement_mutes", "accounts", on_delete: :cascade
  1047. add_foreign_key "announcement_mutes", "announcements", on_delete: :cascade
  1048. add_foreign_key "announcement_reactions", "accounts", on_delete: :cascade
  1049. add_foreign_key "announcement_reactions", "announcements", on_delete: :cascade
  1050. add_foreign_key "announcement_reactions", "custom_emojis", on_delete: :cascade
  1051. add_foreign_key "appeals", "account_warnings", on_delete: :cascade
  1052. add_foreign_key "appeals", "accounts", column: "approved_by_account_id", on_delete: :nullify
  1053. add_foreign_key "appeals", "accounts", column: "rejected_by_account_id", on_delete: :nullify
  1054. add_foreign_key "appeals", "accounts", on_delete: :cascade
  1055. add_foreign_key "backups", "users", on_delete: :nullify
  1056. add_foreign_key "blocks", "accounts", column: "target_account_id", name: "fk_9571bfabc1", on_delete: :cascade
  1057. add_foreign_key "blocks", "accounts", name: "fk_4269e03e65", on_delete: :cascade
  1058. add_foreign_key "bookmarks", "accounts", on_delete: :cascade
  1059. add_foreign_key "bookmarks", "statuses", on_delete: :cascade
  1060. add_foreign_key "canonical_email_blocks", "accounts", column: "reference_account_id", on_delete: :cascade
  1061. add_foreign_key "conversation_mutes", "accounts", name: "fk_225b4212bb", on_delete: :cascade
  1062. add_foreign_key "conversation_mutes", "conversations", on_delete: :cascade
  1063. add_foreign_key "custom_filter_keywords", "custom_filters", on_delete: :cascade
  1064. add_foreign_key "custom_filter_statuses", "custom_filters", on_delete: :cascade
  1065. add_foreign_key "custom_filter_statuses", "statuses", on_delete: :cascade
  1066. add_foreign_key "custom_filters", "accounts", on_delete: :cascade
  1067. add_foreign_key "devices", "accounts", on_delete: :cascade
  1068. add_foreign_key "devices", "oauth_access_tokens", column: "access_token_id", on_delete: :cascade
  1069. add_foreign_key "email_domain_blocks", "email_domain_blocks", column: "parent_id", on_delete: :cascade
  1070. add_foreign_key "encrypted_messages", "accounts", column: "from_account_id", on_delete: :cascade
  1071. add_foreign_key "encrypted_messages", "devices", on_delete: :cascade
  1072. add_foreign_key "favourites", "accounts", name: "fk_5eb6c2b873", on_delete: :cascade
  1073. add_foreign_key "favourites", "statuses", name: "fk_b0e856845e", on_delete: :cascade
  1074. add_foreign_key "featured_tags", "accounts", on_delete: :cascade
  1075. add_foreign_key "featured_tags", "tags", on_delete: :cascade
  1076. add_foreign_key "follow_recommendation_suppressions", "accounts", on_delete: :cascade
  1077. add_foreign_key "follow_requests", "accounts", column: "target_account_id", name: "fk_9291ec025d", on_delete: :cascade
  1078. add_foreign_key "follow_requests", "accounts", name: "fk_76d644b0e7", on_delete: :cascade
  1079. add_foreign_key "follows", "accounts", column: "target_account_id", name: "fk_745ca29eac", on_delete: :cascade
  1080. add_foreign_key "follows", "accounts", name: "fk_32ed1b5560", on_delete: :cascade
  1081. add_foreign_key "identities", "users", name: "fk_bea040f377", on_delete: :cascade
  1082. add_foreign_key "imports", "accounts", name: "fk_6db1b6e408", on_delete: :cascade
  1083. add_foreign_key "invites", "users", on_delete: :cascade
  1084. add_foreign_key "list_accounts", "accounts", on_delete: :cascade
  1085. add_foreign_key "list_accounts", "follows", on_delete: :cascade
  1086. add_foreign_key "list_accounts", "lists", on_delete: :cascade
  1087. add_foreign_key "lists", "accounts", on_delete: :cascade
  1088. add_foreign_key "login_activities", "users", on_delete: :cascade
  1089. add_foreign_key "markers", "users", on_delete: :cascade
  1090. add_foreign_key "media_attachments", "accounts", name: "fk_96dd81e81b", on_delete: :nullify
  1091. add_foreign_key "media_attachments", "scheduled_statuses", on_delete: :nullify
  1092. add_foreign_key "media_attachments", "statuses", on_delete: :nullify
  1093. add_foreign_key "mentions", "accounts", name: "fk_970d43f9d1", on_delete: :cascade
  1094. add_foreign_key "mentions", "statuses", on_delete: :cascade
  1095. add_foreign_key "mutes", "accounts", column: "target_account_id", name: "fk_eecff219ea", on_delete: :cascade
  1096. add_foreign_key "mutes", "accounts", name: "fk_b8d8daf315", on_delete: :cascade
  1097. add_foreign_key "notifications", "accounts", column: "from_account_id", name: "fk_fbd6b0bf9e", on_delete: :cascade
  1098. add_foreign_key "notifications", "accounts", name: "fk_c141c8ee55", on_delete: :cascade
  1099. add_foreign_key "oauth_access_grants", "oauth_applications", column: "application_id", name: "fk_34d54b0a33", on_delete: :cascade
  1100. add_foreign_key "oauth_access_grants", "users", column: "resource_owner_id", name: "fk_63b044929b", on_delete: :cascade
  1101. add_foreign_key "oauth_access_tokens", "oauth_applications", column: "application_id", name: "fk_f5fc4c1ee3", on_delete: :cascade
  1102. add_foreign_key "oauth_access_tokens", "users", column: "resource_owner_id", name: "fk_e84df68546", on_delete: :cascade
  1103. add_foreign_key "oauth_applications", "users", column: "owner_id", name: "fk_b0988c7c0a", on_delete: :cascade
  1104. add_foreign_key "one_time_keys", "devices", on_delete: :cascade
  1105. add_foreign_key "poll_votes", "accounts", on_delete: :cascade
  1106. add_foreign_key "poll_votes", "polls", on_delete: :cascade
  1107. add_foreign_key "polls", "accounts", on_delete: :cascade
  1108. add_foreign_key "polls", "statuses", on_delete: :cascade
  1109. add_foreign_key "preview_card_trends", "preview_cards", on_delete: :cascade
  1110. add_foreign_key "report_notes", "accounts", on_delete: :cascade
  1111. add_foreign_key "report_notes", "reports", on_delete: :cascade
  1112. add_foreign_key "reports", "accounts", column: "action_taken_by_account_id", name: "fk_bca45b75fd", on_delete: :nullify
  1113. add_foreign_key "reports", "accounts", column: "assigned_account_id", on_delete: :nullify
  1114. add_foreign_key "reports", "accounts", column: "target_account_id", name: "fk_eb37af34f0", on_delete: :cascade
  1115. add_foreign_key "reports", "accounts", name: "fk_4b81f7522c", on_delete: :cascade
  1116. add_foreign_key "scheduled_statuses", "accounts", on_delete: :cascade
  1117. add_foreign_key "session_activations", "oauth_access_tokens", column: "access_token_id", name: "fk_957e5bda89", on_delete: :cascade
  1118. add_foreign_key "session_activations", "users", name: "fk_e5fda67334", on_delete: :cascade
  1119. add_foreign_key "status_edits", "accounts", on_delete: :nullify
  1120. add_foreign_key "status_edits", "statuses", on_delete: :cascade
  1121. add_foreign_key "status_pins", "accounts", name: "fk_d4cb435b62", on_delete: :cascade
  1122. add_foreign_key "status_pins", "statuses", on_delete: :cascade
  1123. add_foreign_key "status_stats", "statuses", on_delete: :cascade
  1124. add_foreign_key "status_trends", "accounts", on_delete: :cascade
  1125. add_foreign_key "status_trends", "statuses", on_delete: :cascade
  1126. add_foreign_key "statuses", "accounts", column: "in_reply_to_account_id", name: "fk_c7fa917661", on_delete: :nullify
  1127. add_foreign_key "statuses", "accounts", name: "fk_9bda1543f7", on_delete: :cascade
  1128. add_foreign_key "statuses", "statuses", column: "in_reply_to_id", on_delete: :nullify
  1129. add_foreign_key "statuses", "statuses", column: "reblog_of_id", on_delete: :cascade
  1130. add_foreign_key "statuses_tags", "statuses", on_delete: :cascade
  1131. add_foreign_key "statuses_tags", "tags", name: "fk_3081861e21", on_delete: :cascade
  1132. add_foreign_key "tag_follows", "accounts", on_delete: :cascade
  1133. add_foreign_key "tag_follows", "tags", on_delete: :cascade
  1134. add_foreign_key "tombstones", "accounts", on_delete: :cascade
  1135. add_foreign_key "user_invite_requests", "users", on_delete: :cascade
  1136. add_foreign_key "users", "accounts", name: "fk_50500f500d", on_delete: :cascade
  1137. add_foreign_key "users", "invites", on_delete: :nullify
  1138. add_foreign_key "users", "oauth_applications", column: "created_by_application_id", on_delete: :nullify
  1139. add_foreign_key "users", "user_roles", column: "role_id", on_delete: :nullify
  1140. add_foreign_key "web_push_subscriptions", "oauth_access_tokens", column: "access_token_id", on_delete: :cascade
  1141. add_foreign_key "web_push_subscriptions", "users", on_delete: :cascade
  1142. add_foreign_key "web_settings", "users", name: "fk_11910667b2", on_delete: :cascade
  1143. add_foreign_key "webauthn_credentials", "users"
  1144. create_view "instances", materialized: true, sql_definition: <<-SQL
  1145. WITH domain_counts(domain, accounts_count) AS (
  1146. SELECT accounts.domain,
  1147. count(*) AS accounts_count
  1148. FROM accounts
  1149. WHERE (accounts.domain IS NOT NULL)
  1150. GROUP BY accounts.domain
  1151. )
  1152. SELECT domain_counts.domain,
  1153. domain_counts.accounts_count
  1154. FROM domain_counts
  1155. UNION
  1156. SELECT domain_blocks.domain,
  1157. COALESCE(domain_counts.accounts_count, (0)::bigint) AS accounts_count
  1158. FROM (domain_blocks
  1159. LEFT JOIN domain_counts ON (((domain_counts.domain)::text = (domain_blocks.domain)::text)))
  1160. UNION
  1161. SELECT domain_allows.domain,
  1162. COALESCE(domain_counts.accounts_count, (0)::bigint) AS accounts_count
  1163. FROM (domain_allows
  1164. LEFT JOIN domain_counts ON (((domain_counts.domain)::text = (domain_allows.domain)::text)));
  1165. SQL
  1166. add_index "instances", ["domain"], name: "index_instances_on_domain", unique: true
  1167. create_view "user_ips", sql_definition: <<-SQL
  1168. SELECT t0.user_id,
  1169. t0.ip,
  1170. max(t0.used_at) AS used_at
  1171. FROM ( SELECT users.id AS user_id,
  1172. users.sign_up_ip AS ip,
  1173. users.created_at AS used_at
  1174. FROM users
  1175. WHERE (users.sign_up_ip IS NOT NULL)
  1176. UNION ALL
  1177. SELECT session_activations.user_id,
  1178. session_activations.ip,
  1179. session_activations.updated_at
  1180. FROM session_activations
  1181. UNION ALL
  1182. SELECT login_activities.user_id,
  1183. login_activities.ip,
  1184. login_activities.created_at
  1185. FROM login_activities
  1186. WHERE (login_activities.success = true)) t0
  1187. GROUP BY t0.user_id, t0.ip;
  1188. SQL
  1189. create_view "account_summaries", materialized: true, sql_definition: <<-SQL
  1190. SELECT accounts.id AS account_id,
  1191. mode() WITHIN GROUP (ORDER BY t0.language) AS language,
  1192. mode() WITHIN GROUP (ORDER BY t0.sensitive) AS sensitive
  1193. FROM (accounts
  1194. CROSS JOIN LATERAL ( SELECT statuses.account_id,
  1195. statuses.language,
  1196. statuses.sensitive
  1197. FROM statuses
  1198. WHERE ((statuses.account_id = accounts.id) AND (statuses.deleted_at IS NULL) AND (statuses.reblog_of_id IS NULL))
  1199. ORDER BY statuses.id DESC
  1200. LIMIT 20) t0)
  1201. WHERE ((accounts.suspended_at IS NULL) AND (accounts.silenced_at IS NULL) AND (accounts.moved_to_account_id IS NULL) AND (accounts.discoverable = true) AND (accounts.locked = false))
  1202. GROUP BY accounts.id;
  1203. SQL
  1204. add_index "account_summaries", ["account_id"], name: "index_account_summaries_on_account_id", unique: true
  1205. create_view "follow_recommendations", materialized: true, sql_definition: <<-SQL
  1206. SELECT t0.account_id,
  1207. sum(t0.rank) AS rank,
  1208. array_agg(t0.reason) AS reason
  1209. FROM ( SELECT account_summaries.account_id,
  1210. ((count(follows.id))::numeric / (1.0 + (count(follows.id))::numeric)) AS rank,
  1211. 'most_followed'::text AS reason
  1212. FROM (((follows
  1213. JOIN account_summaries ON ((account_summaries.account_id = follows.target_account_id)))
  1214. JOIN users ON ((users.account_id = follows.account_id)))
  1215. LEFT JOIN follow_recommendation_suppressions ON ((follow_recommendation_suppressions.account_id = follows.target_account_id)))
  1216. WHERE ((users.current_sign_in_at >= (now() - 'P30D'::interval)) AND (account_summaries.sensitive = false) AND (follow_recommendation_suppressions.id IS NULL))
  1217. GROUP BY account_summaries.account_id
  1218. HAVING (count(follows.id) >= 5)
  1219. UNION ALL
  1220. SELECT account_summaries.account_id,
  1221. (sum((status_stats.reblogs_count + status_stats.favourites_count)) / (1.0 + sum((status_stats.reblogs_count + status_stats.favourites_count)))) AS rank,
  1222. 'most_interactions'::text AS reason
  1223. FROM (((status_stats
  1224. JOIN statuses ON ((statuses.id = status_stats.status_id)))
  1225. JOIN account_summaries ON ((account_summaries.account_id = statuses.account_id)))
  1226. LEFT JOIN follow_recommendation_suppressions ON ((follow_recommendation_suppressions.account_id = statuses.account_id)))
  1227. WHERE ((statuses.id >= (((date_part('epoch'::text, (now() - 'P30D'::interval)) * (1000)::double precision))::bigint << 16)) AND (account_summaries.sensitive = false) AND (follow_recommendation_suppressions.id IS NULL))
  1228. GROUP BY account_summaries.account_id
  1229. HAVING (sum((status_stats.reblogs_count + status_stats.favourites_count)) >= (5)::numeric)) t0
  1230. GROUP BY t0.account_id
  1231. ORDER BY (sum(t0.rank)) DESC;
  1232. SQL
  1233. add_index "follow_recommendations", ["account_id"], name: "index_follow_recommendations_on_account_id", unique: true
  1234. end