1
0

schema.rb 71 KB

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