schema.rb 73 KB

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