1
0

schema.rb 65 KB

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