schema.rb 66 KB

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