schema.rb 56 KB

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