schema.rb 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075
  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. # Note that this schema.rb definition is the authoritative source for your
  6. # database schema. If you need to create the application database on another
  7. # system, you should be using db:schema:load, not running all the migrations
  8. # from scratch. The latter is a flawed and unsustainable approach (the more migrations
  9. # you'll amass, the slower it'll run and the greater likelihood for issues).
  10. #
  11. # It's strongly recommended that you check this file into your version control system.
  12. ActiveRecord::Schema.define(version: 2020_12_18_054746) 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_identity_proofs", force: :cascade do |t|
  48. t.bigint "account_id"
  49. t.string "provider", default: "", null: false
  50. t.string "provider_username", default: "", null: false
  51. t.text "token", default: "", null: false
  52. t.boolean "verified", default: false, null: false
  53. t.boolean "live", default: false, null: false
  54. t.datetime "created_at", null: false
  55. t.datetime "updated_at", null: false
  56. t.index ["account_id", "provider", "provider_username"], name: "index_account_proofs_on_account_and_provider_and_username", unique: true
  57. end
  58. create_table "account_migrations", force: :cascade do |t|
  59. t.bigint "account_id"
  60. t.string "acct", default: "", null: false
  61. t.bigint "followers_count", default: 0, null: false
  62. t.bigint "target_account_id"
  63. t.datetime "created_at", null: false
  64. t.datetime "updated_at", null: false
  65. t.index ["account_id"], name: "index_account_migrations_on_account_id"
  66. t.index ["target_account_id"], name: "index_account_migrations_on_target_account_id"
  67. end
  68. create_table "account_moderation_notes", force: :cascade do |t|
  69. t.text "content", null: false
  70. t.bigint "account_id", null: false
  71. t.bigint "target_account_id", null: false
  72. t.datetime "created_at", null: false
  73. t.datetime "updated_at", null: false
  74. t.index ["account_id"], name: "index_account_moderation_notes_on_account_id"
  75. t.index ["target_account_id"], name: "index_account_moderation_notes_on_target_account_id"
  76. end
  77. create_table "account_notes", force: :cascade do |t|
  78. t.bigint "account_id"
  79. t.bigint "target_account_id"
  80. t.text "comment", null: false
  81. t.datetime "created_at", null: false
  82. t.datetime "updated_at", null: false
  83. t.index ["account_id", "target_account_id"], name: "index_account_notes_on_account_id_and_target_account_id", unique: true
  84. t.index ["target_account_id"], name: "index_account_notes_on_target_account_id"
  85. end
  86. create_table "account_pins", force: :cascade do |t|
  87. t.bigint "account_id"
  88. t.bigint "target_account_id"
  89. t.datetime "created_at", null: false
  90. t.datetime "updated_at", null: false
  91. t.index ["account_id", "target_account_id"], name: "index_account_pins_on_account_id_and_target_account_id", unique: true
  92. t.index ["target_account_id"], name: "index_account_pins_on_target_account_id"
  93. end
  94. create_table "account_stats", force: :cascade do |t|
  95. t.bigint "account_id", null: false
  96. t.bigint "statuses_count", default: 0, null: false
  97. t.bigint "following_count", default: 0, null: false
  98. t.bigint "followers_count", default: 0, null: false
  99. t.datetime "created_at", null: false
  100. t.datetime "updated_at", null: false
  101. t.datetime "last_status_at"
  102. t.integer "lock_version", default: 0, null: false
  103. t.index ["account_id"], name: "index_account_stats_on_account_id", unique: true
  104. end
  105. create_table "account_tag_stats", force: :cascade do |t|
  106. t.bigint "tag_id", null: false
  107. t.bigint "accounts_count", default: 0, null: false
  108. t.boolean "hidden", default: false, null: false
  109. t.datetime "created_at", null: false
  110. t.datetime "updated_at", null: false
  111. t.index ["tag_id"], name: "index_account_tag_stats_on_tag_id", unique: true
  112. end
  113. create_table "account_warning_presets", force: :cascade do |t|
  114. t.text "text", default: "", null: false
  115. t.datetime "created_at", null: false
  116. t.datetime "updated_at", null: false
  117. t.string "title", default: "", null: false
  118. end
  119. create_table "account_warnings", force: :cascade do |t|
  120. t.bigint "account_id"
  121. t.bigint "target_account_id"
  122. t.integer "action", default: 0, null: false
  123. t.text "text", default: "", null: false
  124. t.datetime "created_at", null: false
  125. t.datetime "updated_at", null: false
  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", force: :cascade do |t|
  130. t.string "username", default: "", null: false
  131. t.string "domain"
  132. t.string "secret", default: "", null: false
  133. t.text "private_key"
  134. t.text "public_key", default: "", null: false
  135. t.string "remote_url", default: "", null: false
  136. t.string "salmon_url", default: "", null: false
  137. t.string "hub_url", default: "", null: false
  138. t.datetime "created_at", null: false
  139. t.datetime "updated_at", null: false
  140. t.text "note", default: "", null: false
  141. t.string "display_name", default: "", null: false
  142. t.string "uri", default: "", null: false
  143. t.string "url"
  144. t.string "avatar_file_name"
  145. t.string "avatar_content_type"
  146. t.integer "avatar_file_size"
  147. t.datetime "avatar_updated_at"
  148. t.string "header_file_name"
  149. t.string "header_content_type"
  150. t.integer "header_file_size"
  151. t.datetime "header_updated_at"
  152. t.string "avatar_remote_url"
  153. t.datetime "subscription_expires_at"
  154. t.boolean "locked", default: false, null: false
  155. t.string "header_remote_url", default: "", null: false
  156. t.datetime "last_webfingered_at"
  157. t.string "inbox_url", default: "", null: false
  158. t.string "outbox_url", default: "", null: false
  159. t.string "shared_inbox_url", default: "", null: false
  160. t.string "followers_url", default: "", null: false
  161. t.integer "protocol", default: 0, null: false
  162. t.boolean "memorial", default: false, null: false
  163. t.bigint "moved_to_account_id"
  164. t.string "featured_collection_url"
  165. t.jsonb "fields"
  166. t.string "actor_type"
  167. t.boolean "discoverable"
  168. t.string "also_known_as", array: true
  169. t.datetime "silenced_at"
  170. t.datetime "suspended_at"
  171. t.integer "trust_level"
  172. t.boolean "hide_collections"
  173. t.integer "avatar_storage_schema_version"
  174. t.integer "header_storage_schema_version"
  175. t.string "devices_url"
  176. t.integer "suspension_origin"
  177. t.datetime "sensitized_at"
  178. 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
  179. t.index "lower((username)::text), COALESCE(lower((domain)::text), ''::text)", name: "index_accounts_on_username_and_domain_lower", unique: true
  180. t.index ["moved_to_account_id"], name: "index_accounts_on_moved_to_account_id"
  181. t.index ["uri"], name: "index_accounts_on_uri"
  182. t.index ["url"], name: "index_accounts_on_url"
  183. end
  184. create_table "accounts_tags", id: false, force: :cascade do |t|
  185. t.bigint "account_id", null: false
  186. t.bigint "tag_id", null: false
  187. t.index ["account_id", "tag_id"], name: "index_accounts_tags_on_account_id_and_tag_id"
  188. t.index ["tag_id", "account_id"], name: "index_accounts_tags_on_tag_id_and_account_id", unique: true
  189. end
  190. create_table "admin_action_logs", force: :cascade do |t|
  191. t.bigint "account_id"
  192. t.string "action", default: "", null: false
  193. t.string "target_type"
  194. t.bigint "target_id"
  195. t.text "recorded_changes", default: "", null: false
  196. t.datetime "created_at", null: false
  197. t.datetime "updated_at", null: false
  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", null: false
  205. t.datetime "updated_at", 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", null: false
  215. t.datetime "updated_at", 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"
  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"
  225. t.datetime "starts_at"
  226. t.datetime "ends_at"
  227. t.datetime "created_at", null: false
  228. t.datetime "updated_at", null: false
  229. t.datetime "published_at"
  230. t.bigint "status_ids", array: true
  231. end
  232. create_table "backups", force: :cascade do |t|
  233. t.bigint "user_id"
  234. t.string "dump_file_name"
  235. t.string "dump_content_type"
  236. t.datetime "dump_updated_at"
  237. t.boolean "processed", default: false, null: false
  238. t.datetime "created_at", null: false
  239. t.datetime "updated_at", null: false
  240. t.bigint "dump_file_size"
  241. end
  242. create_table "blocks", force: :cascade do |t|
  243. t.datetime "created_at", null: false
  244. t.datetime "updated_at", null: false
  245. t.bigint "account_id", null: false
  246. t.bigint "target_account_id", null: false
  247. t.string "uri"
  248. t.index ["account_id", "target_account_id"], name: "index_blocks_on_account_id_and_target_account_id", unique: true
  249. t.index ["target_account_id"], name: "index_blocks_on_target_account_id"
  250. end
  251. create_table "bookmarks", force: :cascade do |t|
  252. t.bigint "account_id", null: false
  253. t.bigint "status_id", null: false
  254. t.datetime "created_at", null: false
  255. t.datetime "updated_at", null: false
  256. t.index ["account_id", "status_id"], name: "index_bookmarks_on_account_id_and_status_id", unique: true
  257. t.index ["status_id"], name: "index_bookmarks_on_status_id"
  258. end
  259. create_table "conversation_mutes", force: :cascade do |t|
  260. t.bigint "conversation_id", null: false
  261. t.bigint "account_id", null: false
  262. t.index ["account_id", "conversation_id"], name: "index_conversation_mutes_on_account_id_and_conversation_id", unique: true
  263. end
  264. create_table "conversations", force: :cascade do |t|
  265. t.string "uri"
  266. t.datetime "created_at", null: false
  267. t.datetime "updated_at", null: false
  268. t.index ["uri"], name: "index_conversations_on_uri", unique: true
  269. end
  270. create_table "custom_emoji_categories", force: :cascade do |t|
  271. t.string "name"
  272. t.datetime "created_at", null: false
  273. t.datetime "updated_at", null: false
  274. t.index ["name"], name: "index_custom_emoji_categories_on_name", unique: true
  275. end
  276. create_table "custom_emojis", force: :cascade do |t|
  277. t.string "shortcode", default: "", null: false
  278. t.string "domain"
  279. t.string "image_file_name"
  280. t.string "image_content_type"
  281. t.integer "image_file_size"
  282. t.datetime "image_updated_at"
  283. t.datetime "created_at", null: false
  284. t.datetime "updated_at", null: false
  285. t.boolean "disabled", default: false, null: false
  286. t.string "uri"
  287. t.string "image_remote_url"
  288. t.boolean "visible_in_picker", default: true, null: false
  289. t.bigint "category_id"
  290. t.integer "image_storage_schema_version"
  291. t.index ["shortcode", "domain"], name: "index_custom_emojis_on_shortcode_and_domain", unique: true
  292. end
  293. create_table "custom_filters", force: :cascade do |t|
  294. t.bigint "account_id"
  295. t.datetime "expires_at"
  296. t.text "phrase", default: "", null: false
  297. t.string "context", default: [], null: false, array: true
  298. t.boolean "irreversible", default: false, null: false
  299. t.datetime "created_at", null: false
  300. t.datetime "updated_at", null: false
  301. t.boolean "whole_word", default: true, null: false
  302. t.index ["account_id"], name: "index_custom_filters_on_account_id"
  303. end
  304. create_table "devices", force: :cascade do |t|
  305. t.bigint "access_token_id"
  306. t.bigint "account_id"
  307. t.string "device_id", default: "", null: false
  308. t.string "name", default: "", null: false
  309. t.text "fingerprint_key", default: "", null: false
  310. t.text "identity_key", default: "", null: false
  311. t.datetime "created_at", null: false
  312. t.datetime "updated_at", null: false
  313. t.index ["access_token_id"], name: "index_devices_on_access_token_id"
  314. t.index ["account_id"], name: "index_devices_on_account_id"
  315. end
  316. create_table "domain_allows", force: :cascade do |t|
  317. t.string "domain", default: "", null: false
  318. t.datetime "created_at", null: false
  319. t.datetime "updated_at", null: false
  320. t.index ["domain"], name: "index_domain_allows_on_domain", unique: true
  321. end
  322. create_table "domain_blocks", force: :cascade do |t|
  323. t.string "domain", default: "", null: false
  324. t.datetime "created_at", null: false
  325. t.datetime "updated_at", null: false
  326. t.integer "severity", default: 0
  327. t.boolean "reject_media", default: false, null: false
  328. t.boolean "reject_reports", default: false, null: false
  329. t.text "private_comment"
  330. t.text "public_comment"
  331. t.boolean "obfuscate", default: false, null: false
  332. t.index ["domain"], name: "index_domain_blocks_on_domain", unique: true
  333. end
  334. create_table "email_domain_blocks", force: :cascade do |t|
  335. t.string "domain", default: "", null: false
  336. t.datetime "created_at", null: false
  337. t.datetime "updated_at", null: false
  338. t.bigint "parent_id"
  339. t.index ["domain"], name: "index_email_domain_blocks_on_domain", unique: true
  340. end
  341. create_table "encrypted_messages", id: :bigint, default: -> { "timestamp_id('encrypted_messages'::text)" }, force: :cascade do |t|
  342. t.bigint "device_id"
  343. t.bigint "from_account_id"
  344. t.string "from_device_id", default: "", null: false
  345. t.integer "type", default: 0, null: false
  346. t.text "body", default: "", null: false
  347. t.text "digest", default: "", null: false
  348. t.text "message_franking", default: "", null: false
  349. t.datetime "created_at", null: false
  350. t.datetime "updated_at", null: false
  351. t.index ["device_id"], name: "index_encrypted_messages_on_device_id"
  352. t.index ["from_account_id"], name: "index_encrypted_messages_on_from_account_id"
  353. end
  354. create_table "favourites", force: :cascade do |t|
  355. t.datetime "created_at", null: false
  356. t.datetime "updated_at", null: false
  357. t.bigint "account_id", null: false
  358. t.bigint "status_id", null: false
  359. t.index ["account_id", "id"], name: "index_favourites_on_account_id_and_id"
  360. t.index ["account_id", "status_id"], name: "index_favourites_on_account_id_and_status_id", unique: true
  361. t.index ["status_id"], name: "index_favourites_on_status_id"
  362. end
  363. create_table "featured_tags", force: :cascade do |t|
  364. t.bigint "account_id"
  365. t.bigint "tag_id"
  366. t.bigint "statuses_count", default: 0, null: false
  367. t.datetime "last_status_at"
  368. t.datetime "created_at", null: false
  369. t.datetime "updated_at", null: false
  370. t.index ["account_id"], name: "index_featured_tags_on_account_id"
  371. t.index ["tag_id"], name: "index_featured_tags_on_tag_id"
  372. end
  373. create_table "follow_requests", force: :cascade do |t|
  374. t.datetime "created_at", null: false
  375. t.datetime "updated_at", null: false
  376. t.bigint "account_id", null: false
  377. t.bigint "target_account_id", null: false
  378. t.boolean "show_reblogs", default: true, null: false
  379. t.string "uri"
  380. t.boolean "notify", default: false, null: false
  381. t.index ["account_id", "target_account_id"], name: "index_follow_requests_on_account_id_and_target_account_id", unique: true
  382. end
  383. create_table "follows", force: :cascade do |t|
  384. t.datetime "created_at", null: false
  385. t.datetime "updated_at", null: false
  386. t.bigint "account_id", null: false
  387. t.bigint "target_account_id", null: false
  388. t.boolean "show_reblogs", default: true, null: false
  389. t.string "uri"
  390. t.boolean "notify", default: false, null: false
  391. t.index ["account_id", "target_account_id"], name: "index_follows_on_account_id_and_target_account_id", unique: true
  392. t.index ["target_account_id"], name: "index_follows_on_target_account_id"
  393. end
  394. create_table "identities", force: :cascade do |t|
  395. t.string "provider", default: "", null: false
  396. t.string "uid", default: "", null: false
  397. t.datetime "created_at", null: false
  398. t.datetime "updated_at", null: false
  399. t.bigint "user_id"
  400. t.index ["user_id"], name: "index_identities_on_user_id"
  401. end
  402. create_table "imports", force: :cascade do |t|
  403. t.integer "type", null: false
  404. t.boolean "approved", default: false, null: false
  405. t.datetime "created_at", null: false
  406. t.datetime "updated_at", null: false
  407. t.string "data_file_name"
  408. t.string "data_content_type"
  409. t.integer "data_file_size"
  410. t.datetime "data_updated_at"
  411. t.bigint "account_id", null: false
  412. t.boolean "overwrite", default: false, null: false
  413. end
  414. create_table "invites", force: :cascade do |t|
  415. t.bigint "user_id", null: false
  416. t.string "code", default: "", null: false
  417. t.datetime "expires_at"
  418. t.integer "max_uses"
  419. t.integer "uses", default: 0, null: false
  420. t.datetime "created_at", null: false
  421. t.datetime "updated_at", null: false
  422. t.boolean "autofollow", default: false, null: false
  423. t.text "comment"
  424. t.index ["code"], name: "index_invites_on_code", unique: true
  425. t.index ["user_id"], name: "index_invites_on_user_id"
  426. end
  427. create_table "ip_blocks", force: :cascade do |t|
  428. t.datetime "created_at", null: false
  429. t.datetime "updated_at", null: false
  430. t.datetime "expires_at"
  431. t.inet "ip", default: "0.0.0.0", null: false
  432. t.integer "severity", default: 0, null: false
  433. t.text "comment", default: "", null: false
  434. end
  435. create_table "list_accounts", force: :cascade do |t|
  436. t.bigint "list_id", null: false
  437. t.bigint "account_id", null: false
  438. t.bigint "follow_id"
  439. t.index ["account_id", "list_id"], name: "index_list_accounts_on_account_id_and_list_id", unique: true
  440. t.index ["follow_id"], name: "index_list_accounts_on_follow_id"
  441. t.index ["list_id", "account_id"], name: "index_list_accounts_on_list_id_and_account_id"
  442. end
  443. create_table "lists", force: :cascade do |t|
  444. t.bigint "account_id", null: false
  445. t.string "title", default: "", null: false
  446. t.datetime "created_at", null: false
  447. t.datetime "updated_at", null: false
  448. t.integer "replies_policy", default: 0, null: false
  449. t.index ["account_id"], name: "index_lists_on_account_id"
  450. end
  451. create_table "markers", force: :cascade do |t|
  452. t.bigint "user_id"
  453. t.string "timeline", default: "", null: false
  454. t.bigint "last_read_id", default: 0, null: false
  455. t.integer "lock_version", default: 0, null: false
  456. t.datetime "created_at", null: false
  457. t.datetime "updated_at", null: false
  458. t.index ["user_id", "timeline"], name: "index_markers_on_user_id_and_timeline", unique: true
  459. end
  460. create_table "media_attachments", id: :bigint, default: -> { "timestamp_id('media_attachments'::text)" }, force: :cascade do |t|
  461. t.bigint "status_id"
  462. t.string "file_file_name"
  463. t.string "file_content_type"
  464. t.integer "file_file_size"
  465. t.datetime "file_updated_at"
  466. t.string "remote_url", default: "", null: false
  467. t.datetime "created_at", null: false
  468. t.datetime "updated_at", null: false
  469. t.string "shortcode"
  470. t.integer "type", default: 0, null: false
  471. t.json "file_meta"
  472. t.bigint "account_id"
  473. t.text "description"
  474. t.bigint "scheduled_status_id"
  475. t.string "blurhash"
  476. t.integer "processing"
  477. t.integer "file_storage_schema_version"
  478. t.string "thumbnail_file_name"
  479. t.string "thumbnail_content_type"
  480. t.integer "thumbnail_file_size"
  481. t.datetime "thumbnail_updated_at"
  482. t.string "thumbnail_remote_url"
  483. t.index ["account_id"], name: "index_media_attachments_on_account_id"
  484. t.index ["scheduled_status_id"], name: "index_media_attachments_on_scheduled_status_id"
  485. t.index ["shortcode"], name: "index_media_attachments_on_shortcode", unique: true
  486. t.index ["status_id"], name: "index_media_attachments_on_status_id"
  487. end
  488. create_table "mentions", force: :cascade do |t|
  489. t.bigint "status_id"
  490. t.datetime "created_at", null: false
  491. t.datetime "updated_at", null: false
  492. t.bigint "account_id"
  493. t.boolean "silent", default: false, null: false
  494. t.index ["account_id", "status_id"], name: "index_mentions_on_account_id_and_status_id", unique: true
  495. t.index ["status_id"], name: "index_mentions_on_status_id"
  496. end
  497. create_table "mutes", force: :cascade do |t|
  498. t.datetime "created_at", null: false
  499. t.datetime "updated_at", null: false
  500. t.boolean "hide_notifications", default: true, null: false
  501. t.bigint "account_id", null: false
  502. t.bigint "target_account_id", null: false
  503. t.datetime "expires_at"
  504. t.index ["account_id", "target_account_id"], name: "index_mutes_on_account_id_and_target_account_id", unique: true
  505. t.index ["target_account_id"], name: "index_mutes_on_target_account_id"
  506. end
  507. create_table "notifications", force: :cascade do |t|
  508. t.bigint "activity_id", null: false
  509. t.string "activity_type", null: false
  510. t.datetime "created_at", null: false
  511. t.datetime "updated_at", null: false
  512. t.bigint "account_id", null: false
  513. t.bigint "from_account_id", null: false
  514. t.string "type"
  515. t.index ["account_id", "id", "type"], name: "index_notifications_on_account_id_and_id_and_type", order: { id: :desc }
  516. t.index ["activity_id", "activity_type"], name: "index_notifications_on_activity_id_and_activity_type"
  517. t.index ["from_account_id"], name: "index_notifications_on_from_account_id"
  518. end
  519. create_table "oauth_access_grants", force: :cascade do |t|
  520. t.string "token", null: false
  521. t.integer "expires_in", null: false
  522. t.text "redirect_uri", null: false
  523. t.datetime "created_at", null: false
  524. t.datetime "revoked_at"
  525. t.string "scopes"
  526. t.bigint "application_id", null: false
  527. t.bigint "resource_owner_id", null: false
  528. t.index ["resource_owner_id"], name: "index_oauth_access_grants_on_resource_owner_id"
  529. t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true
  530. end
  531. create_table "oauth_access_tokens", force: :cascade do |t|
  532. t.string "token", null: false
  533. t.string "refresh_token"
  534. t.integer "expires_in"
  535. t.datetime "revoked_at"
  536. t.datetime "created_at", null: false
  537. t.string "scopes"
  538. t.bigint "application_id"
  539. t.bigint "resource_owner_id"
  540. t.index ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true
  541. t.index ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id"
  542. t.index ["token"], name: "index_oauth_access_tokens_on_token", unique: true
  543. end
  544. create_table "oauth_applications", force: :cascade do |t|
  545. t.string "name", null: false
  546. t.string "uid", null: false
  547. t.string "secret", null: false
  548. t.text "redirect_uri", null: false
  549. t.string "scopes", default: "", null: false
  550. t.datetime "created_at"
  551. t.datetime "updated_at"
  552. t.boolean "superapp", default: false, null: false
  553. t.string "website"
  554. t.string "owner_type"
  555. t.bigint "owner_id"
  556. t.boolean "confidential", default: true, null: false
  557. t.index ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type"
  558. t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true
  559. end
  560. create_table "one_time_keys", force: :cascade do |t|
  561. t.bigint "device_id"
  562. t.string "key_id", default: "", null: false
  563. t.text "key", default: "", null: false
  564. t.text "signature", default: "", null: false
  565. t.datetime "created_at", null: false
  566. t.datetime "updated_at", null: false
  567. t.index ["device_id"], name: "index_one_time_keys_on_device_id"
  568. t.index ["key_id"], name: "index_one_time_keys_on_key_id"
  569. end
  570. create_table "pghero_space_stats", force: :cascade do |t|
  571. t.text "database"
  572. t.text "schema"
  573. t.text "relation"
  574. t.bigint "size"
  575. t.datetime "captured_at"
  576. t.index ["database", "captured_at"], name: "index_pghero_space_stats_on_database_and_captured_at"
  577. end
  578. create_table "poll_votes", force: :cascade do |t|
  579. t.bigint "account_id"
  580. t.bigint "poll_id"
  581. t.integer "choice", default: 0, null: false
  582. t.datetime "created_at", null: false
  583. t.datetime "updated_at", null: false
  584. t.string "uri"
  585. t.index ["account_id"], name: "index_poll_votes_on_account_id"
  586. t.index ["poll_id"], name: "index_poll_votes_on_poll_id"
  587. end
  588. create_table "polls", force: :cascade do |t|
  589. t.bigint "account_id"
  590. t.bigint "status_id"
  591. t.datetime "expires_at"
  592. t.string "options", default: [], null: false, array: true
  593. t.bigint "cached_tallies", default: [], null: false, array: true
  594. t.boolean "multiple", default: false, null: false
  595. t.boolean "hide_totals", default: false, null: false
  596. t.bigint "votes_count", default: 0, null: false
  597. t.datetime "last_fetched_at"
  598. t.datetime "created_at", null: false
  599. t.datetime "updated_at", null: false
  600. t.integer "lock_version", default: 0, null: false
  601. t.bigint "voters_count"
  602. t.index ["account_id"], name: "index_polls_on_account_id"
  603. t.index ["status_id"], name: "index_polls_on_status_id"
  604. end
  605. create_table "preview_cards", force: :cascade do |t|
  606. t.string "url", default: "", null: false
  607. t.string "title", default: "", null: false
  608. t.string "description", default: "", null: false
  609. t.string "image_file_name"
  610. t.string "image_content_type"
  611. t.integer "image_file_size"
  612. t.datetime "image_updated_at"
  613. t.integer "type", default: 0, null: false
  614. t.text "html", default: "", null: false
  615. t.string "author_name", default: "", null: false
  616. t.string "author_url", default: "", null: false
  617. t.string "provider_name", default: "", null: false
  618. t.string "provider_url", default: "", null: false
  619. t.integer "width", default: 0, null: false
  620. t.integer "height", default: 0, null: false
  621. t.datetime "created_at", null: false
  622. t.datetime "updated_at", null: false
  623. t.string "embed_url", default: "", null: false
  624. t.integer "image_storage_schema_version"
  625. t.string "blurhash"
  626. t.index ["url"], name: "index_preview_cards_on_url", unique: true
  627. end
  628. create_table "preview_cards_statuses", id: false, force: :cascade do |t|
  629. t.bigint "preview_card_id", null: false
  630. t.bigint "status_id", null: false
  631. t.index ["status_id", "preview_card_id"], name: "index_preview_cards_statuses_on_status_id_and_preview_card_id"
  632. end
  633. create_table "relays", force: :cascade do |t|
  634. t.string "inbox_url", default: "", null: false
  635. t.string "follow_activity_id"
  636. t.datetime "created_at", null: false
  637. t.datetime "updated_at", null: false
  638. t.integer "state", default: 0, null: false
  639. end
  640. create_table "report_notes", force: :cascade do |t|
  641. t.text "content", null: false
  642. t.bigint "report_id", null: false
  643. t.bigint "account_id", null: false
  644. t.datetime "created_at", null: false
  645. t.datetime "updated_at", null: false
  646. t.index ["account_id"], name: "index_report_notes_on_account_id"
  647. t.index ["report_id"], name: "index_report_notes_on_report_id"
  648. end
  649. create_table "reports", force: :cascade do |t|
  650. t.bigint "status_ids", default: [], null: false, array: true
  651. t.text "comment", default: "", null: false
  652. t.boolean "action_taken", default: false, null: false
  653. t.datetime "created_at", null: false
  654. t.datetime "updated_at", null: false
  655. t.bigint "account_id", null: false
  656. t.bigint "action_taken_by_account_id"
  657. t.bigint "target_account_id", null: false
  658. t.bigint "assigned_account_id"
  659. t.string "uri"
  660. t.boolean "forwarded"
  661. t.index ["account_id"], name: "index_reports_on_account_id"
  662. t.index ["target_account_id"], name: "index_reports_on_target_account_id"
  663. end
  664. create_table "scheduled_statuses", force: :cascade do |t|
  665. t.bigint "account_id"
  666. t.datetime "scheduled_at"
  667. t.jsonb "params"
  668. t.index ["account_id"], name: "index_scheduled_statuses_on_account_id"
  669. t.index ["scheduled_at"], name: "index_scheduled_statuses_on_scheduled_at"
  670. end
  671. create_table "session_activations", force: :cascade do |t|
  672. t.string "session_id", null: false
  673. t.datetime "created_at", null: false
  674. t.datetime "updated_at", null: false
  675. t.string "user_agent", default: "", null: false
  676. t.inet "ip"
  677. t.bigint "access_token_id"
  678. t.bigint "user_id", null: false
  679. t.bigint "web_push_subscription_id"
  680. t.index ["access_token_id"], name: "index_session_activations_on_access_token_id"
  681. t.index ["session_id"], name: "index_session_activations_on_session_id", unique: true
  682. t.index ["user_id"], name: "index_session_activations_on_user_id"
  683. end
  684. create_table "settings", force: :cascade do |t|
  685. t.string "var", null: false
  686. t.text "value"
  687. t.string "thing_type"
  688. t.datetime "created_at"
  689. t.datetime "updated_at"
  690. t.bigint "thing_id"
  691. t.index ["thing_type", "thing_id", "var"], name: "index_settings_on_thing_type_and_thing_id_and_var", unique: true
  692. end
  693. create_table "site_uploads", force: :cascade do |t|
  694. t.string "var", default: "", null: false
  695. t.string "file_file_name"
  696. t.string "file_content_type"
  697. t.integer "file_file_size"
  698. t.datetime "file_updated_at"
  699. t.json "meta"
  700. t.datetime "created_at", null: false
  701. t.datetime "updated_at", null: false
  702. t.index ["var"], name: "index_site_uploads_on_var", unique: true
  703. end
  704. create_table "status_pins", force: :cascade do |t|
  705. t.bigint "account_id", null: false
  706. t.bigint "status_id", null: false
  707. t.datetime "created_at", default: -> { "now()" }, null: false
  708. t.datetime "updated_at", default: -> { "now()" }, null: false
  709. t.index ["account_id", "status_id"], name: "index_status_pins_on_account_id_and_status_id", unique: true
  710. end
  711. create_table "status_stats", force: :cascade do |t|
  712. t.bigint "status_id", null: false
  713. t.bigint "replies_count", default: 0, null: false
  714. t.bigint "reblogs_count", default: 0, null: false
  715. t.bigint "favourites_count", default: 0, null: false
  716. t.datetime "created_at", null: false
  717. t.datetime "updated_at", null: false
  718. t.index ["status_id"], name: "index_status_stats_on_status_id", unique: true
  719. end
  720. create_table "statuses", id: :bigint, default: -> { "timestamp_id('statuses'::text)" }, force: :cascade do |t|
  721. t.string "uri"
  722. t.text "text", default: "", null: false
  723. t.datetime "created_at", null: false
  724. t.datetime "updated_at", null: false
  725. t.bigint "in_reply_to_id"
  726. t.bigint "reblog_of_id"
  727. t.string "url"
  728. t.boolean "sensitive", default: false, null: false
  729. t.integer "visibility", default: 0, null: false
  730. t.text "spoiler_text", default: "", null: false
  731. t.boolean "reply", default: false, null: false
  732. t.string "language"
  733. t.bigint "conversation_id"
  734. t.boolean "local"
  735. t.bigint "account_id", null: false
  736. t.bigint "application_id"
  737. t.bigint "in_reply_to_account_id"
  738. t.bigint "poll_id"
  739. t.datetime "deleted_at"
  740. t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20190820", order: { id: :desc }, where: "(deleted_at IS NULL)"
  741. 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)))"
  742. 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)))"
  743. t.index ["in_reply_to_account_id"], name: "index_statuses_on_in_reply_to_account_id"
  744. t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id"
  745. t.index ["reblog_of_id", "account_id"], name: "index_statuses_on_reblog_of_id_and_account_id"
  746. t.index ["uri"], name: "index_statuses_on_uri", unique: true
  747. end
  748. create_table "statuses_tags", id: false, force: :cascade do |t|
  749. t.bigint "status_id", null: false
  750. t.bigint "tag_id", null: false
  751. t.index ["status_id"], name: "index_statuses_tags_on_status_id"
  752. t.index ["tag_id", "status_id"], name: "index_statuses_tags_on_tag_id_and_status_id", unique: true
  753. end
  754. create_table "system_keys", force: :cascade do |t|
  755. t.binary "key"
  756. t.datetime "created_at", null: false
  757. t.datetime "updated_at", null: false
  758. end
  759. create_table "tags", force: :cascade do |t|
  760. t.string "name", default: "", null: false
  761. t.datetime "created_at", null: false
  762. t.datetime "updated_at", null: false
  763. t.boolean "usable"
  764. t.boolean "trendable"
  765. t.boolean "listable"
  766. t.datetime "reviewed_at"
  767. t.datetime "requested_review_at"
  768. t.datetime "last_status_at"
  769. t.float "max_score"
  770. t.datetime "max_score_at"
  771. t.index "lower((name)::text)", name: "index_tags_on_name_lower", unique: true
  772. end
  773. create_table "tombstones", force: :cascade do |t|
  774. t.bigint "account_id"
  775. t.string "uri", null: false
  776. t.datetime "created_at", null: false
  777. t.datetime "updated_at", null: false
  778. t.boolean "by_moderator"
  779. t.index ["account_id"], name: "index_tombstones_on_account_id"
  780. t.index ["uri"], name: "index_tombstones_on_uri"
  781. end
  782. create_table "unavailable_domains", force: :cascade do |t|
  783. t.string "domain", default: "", null: false
  784. t.datetime "created_at", null: false
  785. t.datetime "updated_at", null: false
  786. t.index ["domain"], name: "index_unavailable_domains_on_domain", unique: true
  787. end
  788. create_table "user_invite_requests", force: :cascade do |t|
  789. t.bigint "user_id"
  790. t.text "text"
  791. t.datetime "created_at", null: false
  792. t.datetime "updated_at", null: false
  793. t.index ["user_id"], name: "index_user_invite_requests_on_user_id"
  794. end
  795. create_table "users", force: :cascade do |t|
  796. t.string "email", default: "", null: false
  797. t.datetime "created_at", null: false
  798. t.datetime "updated_at", null: false
  799. t.string "encrypted_password", default: "", null: false
  800. t.string "reset_password_token"
  801. t.datetime "reset_password_sent_at"
  802. t.datetime "remember_created_at"
  803. t.integer "sign_in_count", default: 0, null: false
  804. t.datetime "current_sign_in_at"
  805. t.datetime "last_sign_in_at"
  806. t.inet "current_sign_in_ip"
  807. t.inet "last_sign_in_ip"
  808. t.boolean "admin", default: false, null: false
  809. t.string "confirmation_token"
  810. t.datetime "confirmed_at"
  811. t.datetime "confirmation_sent_at"
  812. t.string "unconfirmed_email"
  813. t.string "locale"
  814. t.string "encrypted_otp_secret"
  815. t.string "encrypted_otp_secret_iv"
  816. t.string "encrypted_otp_secret_salt"
  817. t.integer "consumed_timestep"
  818. t.boolean "otp_required_for_login", default: false, null: false
  819. t.datetime "last_emailed_at"
  820. t.string "otp_backup_codes", array: true
  821. t.string "filtered_languages", default: [], null: false, array: true
  822. t.bigint "account_id", null: false
  823. t.boolean "disabled", default: false, null: false
  824. t.boolean "moderator", default: false, null: false
  825. t.bigint "invite_id"
  826. t.string "remember_token"
  827. t.string "chosen_languages", array: true
  828. t.bigint "created_by_application_id"
  829. t.boolean "approved", default: true, null: false
  830. t.string "sign_in_token"
  831. t.datetime "sign_in_token_sent_at"
  832. t.string "webauthn_id"
  833. t.inet "sign_up_ip"
  834. t.index ["account_id"], name: "index_users_on_account_id"
  835. t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
  836. t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id"
  837. t.index ["email"], name: "index_users_on_email", unique: true
  838. t.index ["remember_token"], name: "index_users_on_remember_token", unique: true
  839. t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
  840. end
  841. create_table "web_push_subscriptions", force: :cascade do |t|
  842. t.string "endpoint", null: false
  843. t.string "key_p256dh", null: false
  844. t.string "key_auth", null: false
  845. t.json "data"
  846. t.datetime "created_at", null: false
  847. t.datetime "updated_at", null: false
  848. t.bigint "access_token_id"
  849. t.bigint "user_id"
  850. t.index ["access_token_id"], name: "index_web_push_subscriptions_on_access_token_id"
  851. t.index ["user_id"], name: "index_web_push_subscriptions_on_user_id"
  852. end
  853. create_table "web_settings", force: :cascade do |t|
  854. t.json "data"
  855. t.datetime "created_at", null: false
  856. t.datetime "updated_at", null: false
  857. t.bigint "user_id", null: false
  858. t.index ["user_id"], name: "index_web_settings_on_user_id", unique: true
  859. end
  860. create_table "webauthn_credentials", force: :cascade do |t|
  861. t.string "external_id", null: false
  862. t.string "public_key", null: false
  863. t.string "nickname", null: false
  864. t.bigint "sign_count", default: 0, null: false
  865. t.bigint "user_id"
  866. t.datetime "created_at", null: false
  867. t.datetime "updated_at", null: false
  868. t.index ["external_id"], name: "index_webauthn_credentials_on_external_id", unique: true
  869. t.index ["user_id"], name: "index_webauthn_credentials_on_user_id"
  870. end
  871. add_foreign_key "account_aliases", "accounts", on_delete: :cascade
  872. add_foreign_key "account_conversations", "accounts", on_delete: :cascade
  873. add_foreign_key "account_conversations", "conversations", on_delete: :cascade
  874. add_foreign_key "account_deletion_requests", "accounts", on_delete: :cascade
  875. add_foreign_key "account_domain_blocks", "accounts", name: "fk_206c6029bd", on_delete: :cascade
  876. add_foreign_key "account_identity_proofs", "accounts", on_delete: :cascade
  877. add_foreign_key "account_migrations", "accounts", column: "target_account_id", on_delete: :nullify
  878. add_foreign_key "account_migrations", "accounts", on_delete: :cascade
  879. add_foreign_key "account_moderation_notes", "accounts"
  880. add_foreign_key "account_moderation_notes", "accounts", column: "target_account_id"
  881. add_foreign_key "account_notes", "accounts", column: "target_account_id", on_delete: :cascade
  882. add_foreign_key "account_notes", "accounts", on_delete: :cascade
  883. add_foreign_key "account_pins", "accounts", column: "target_account_id", on_delete: :cascade
  884. add_foreign_key "account_pins", "accounts", on_delete: :cascade
  885. add_foreign_key "account_stats", "accounts", on_delete: :cascade
  886. add_foreign_key "account_tag_stats", "tags", on_delete: :cascade
  887. add_foreign_key "account_warnings", "accounts", column: "target_account_id", on_delete: :cascade
  888. add_foreign_key "account_warnings", "accounts", on_delete: :nullify
  889. add_foreign_key "accounts", "accounts", column: "moved_to_account_id", on_delete: :nullify
  890. add_foreign_key "admin_action_logs", "accounts", on_delete: :cascade
  891. add_foreign_key "announcement_mutes", "accounts", on_delete: :cascade
  892. add_foreign_key "announcement_mutes", "announcements", on_delete: :cascade
  893. add_foreign_key "announcement_reactions", "accounts", on_delete: :cascade
  894. add_foreign_key "announcement_reactions", "announcements", on_delete: :cascade
  895. add_foreign_key "announcement_reactions", "custom_emojis", on_delete: :cascade
  896. add_foreign_key "backups", "users", on_delete: :nullify
  897. add_foreign_key "blocks", "accounts", column: "target_account_id", name: "fk_9571bfabc1", on_delete: :cascade
  898. add_foreign_key "blocks", "accounts", name: "fk_4269e03e65", on_delete: :cascade
  899. add_foreign_key "bookmarks", "accounts", on_delete: :cascade
  900. add_foreign_key "bookmarks", "statuses", on_delete: :cascade
  901. add_foreign_key "conversation_mutes", "accounts", name: "fk_225b4212bb", on_delete: :cascade
  902. add_foreign_key "conversation_mutes", "conversations", on_delete: :cascade
  903. add_foreign_key "custom_filters", "accounts", on_delete: :cascade
  904. add_foreign_key "devices", "accounts", on_delete: :cascade
  905. add_foreign_key "devices", "oauth_access_tokens", column: "access_token_id", on_delete: :cascade
  906. add_foreign_key "email_domain_blocks", "email_domain_blocks", column: "parent_id", on_delete: :cascade
  907. add_foreign_key "encrypted_messages", "accounts", column: "from_account_id", on_delete: :cascade
  908. add_foreign_key "encrypted_messages", "devices", on_delete: :cascade
  909. add_foreign_key "favourites", "accounts", name: "fk_5eb6c2b873", on_delete: :cascade
  910. add_foreign_key "favourites", "statuses", name: "fk_b0e856845e", on_delete: :cascade
  911. add_foreign_key "featured_tags", "accounts", on_delete: :cascade
  912. add_foreign_key "featured_tags", "tags", on_delete: :cascade
  913. add_foreign_key "follow_requests", "accounts", column: "target_account_id", name: "fk_9291ec025d", on_delete: :cascade
  914. add_foreign_key "follow_requests", "accounts", name: "fk_76d644b0e7", on_delete: :cascade
  915. add_foreign_key "follows", "accounts", column: "target_account_id", name: "fk_745ca29eac", on_delete: :cascade
  916. add_foreign_key "follows", "accounts", name: "fk_32ed1b5560", on_delete: :cascade
  917. add_foreign_key "identities", "users", name: "fk_bea040f377", on_delete: :cascade
  918. add_foreign_key "imports", "accounts", name: "fk_6db1b6e408", on_delete: :cascade
  919. add_foreign_key "invites", "users", on_delete: :cascade
  920. add_foreign_key "list_accounts", "accounts", on_delete: :cascade
  921. add_foreign_key "list_accounts", "follows", on_delete: :cascade
  922. add_foreign_key "list_accounts", "lists", on_delete: :cascade
  923. add_foreign_key "lists", "accounts", on_delete: :cascade
  924. add_foreign_key "markers", "users", on_delete: :cascade
  925. add_foreign_key "media_attachments", "accounts", name: "fk_96dd81e81b", on_delete: :nullify
  926. add_foreign_key "media_attachments", "scheduled_statuses", on_delete: :nullify
  927. add_foreign_key "media_attachments", "statuses", on_delete: :nullify
  928. add_foreign_key "mentions", "accounts", name: "fk_970d43f9d1", on_delete: :cascade
  929. add_foreign_key "mentions", "statuses", on_delete: :cascade
  930. add_foreign_key "mutes", "accounts", column: "target_account_id", name: "fk_eecff219ea", on_delete: :cascade
  931. add_foreign_key "mutes", "accounts", name: "fk_b8d8daf315", on_delete: :cascade
  932. add_foreign_key "notifications", "accounts", column: "from_account_id", name: "fk_fbd6b0bf9e", on_delete: :cascade
  933. add_foreign_key "notifications", "accounts", name: "fk_c141c8ee55", on_delete: :cascade
  934. add_foreign_key "oauth_access_grants", "oauth_applications", column: "application_id", name: "fk_34d54b0a33", on_delete: :cascade
  935. add_foreign_key "oauth_access_grants", "users", column: "resource_owner_id", name: "fk_63b044929b", on_delete: :cascade
  936. add_foreign_key "oauth_access_tokens", "oauth_applications", column: "application_id", name: "fk_f5fc4c1ee3", on_delete: :cascade
  937. add_foreign_key "oauth_access_tokens", "users", column: "resource_owner_id", name: "fk_e84df68546", on_delete: :cascade
  938. add_foreign_key "oauth_applications", "users", column: "owner_id", name: "fk_b0988c7c0a", on_delete: :cascade
  939. add_foreign_key "one_time_keys", "devices", on_delete: :cascade
  940. add_foreign_key "poll_votes", "accounts", on_delete: :cascade
  941. add_foreign_key "poll_votes", "polls", on_delete: :cascade
  942. add_foreign_key "polls", "accounts", on_delete: :cascade
  943. add_foreign_key "polls", "statuses", on_delete: :cascade
  944. add_foreign_key "report_notes", "accounts", on_delete: :cascade
  945. add_foreign_key "report_notes", "reports", on_delete: :cascade
  946. add_foreign_key "reports", "accounts", column: "action_taken_by_account_id", name: "fk_bca45b75fd", on_delete: :nullify
  947. add_foreign_key "reports", "accounts", column: "assigned_account_id", on_delete: :nullify
  948. add_foreign_key "reports", "accounts", column: "target_account_id", name: "fk_eb37af34f0", on_delete: :cascade
  949. add_foreign_key "reports", "accounts", name: "fk_4b81f7522c", on_delete: :cascade
  950. add_foreign_key "scheduled_statuses", "accounts", on_delete: :cascade
  951. add_foreign_key "session_activations", "oauth_access_tokens", column: "access_token_id", name: "fk_957e5bda89", on_delete: :cascade
  952. add_foreign_key "session_activations", "users", name: "fk_e5fda67334", on_delete: :cascade
  953. add_foreign_key "status_pins", "accounts", name: "fk_d4cb435b62", on_delete: :cascade
  954. add_foreign_key "status_pins", "statuses", on_delete: :cascade
  955. add_foreign_key "status_stats", "statuses", on_delete: :cascade
  956. add_foreign_key "statuses", "accounts", column: "in_reply_to_account_id", name: "fk_c7fa917661", on_delete: :nullify
  957. add_foreign_key "statuses", "accounts", name: "fk_9bda1543f7", on_delete: :cascade
  958. add_foreign_key "statuses", "statuses", column: "in_reply_to_id", on_delete: :nullify
  959. add_foreign_key "statuses", "statuses", column: "reblog_of_id", on_delete: :cascade
  960. add_foreign_key "statuses_tags", "statuses", on_delete: :cascade
  961. add_foreign_key "statuses_tags", "tags", name: "fk_3081861e21", on_delete: :cascade
  962. add_foreign_key "tombstones", "accounts", on_delete: :cascade
  963. add_foreign_key "user_invite_requests", "users", on_delete: :cascade
  964. add_foreign_key "users", "accounts", name: "fk_50500f500d", on_delete: :cascade
  965. add_foreign_key "users", "invites", on_delete: :nullify
  966. add_foreign_key "users", "oauth_applications", column: "created_by_application_id", on_delete: :nullify
  967. add_foreign_key "web_push_subscriptions", "oauth_access_tokens", column: "access_token_id", on_delete: :cascade
  968. add_foreign_key "web_push_subscriptions", "users", on_delete: :cascade
  969. add_foreign_key "web_settings", "users", name: "fk_11910667b2", on_delete: :cascade
  970. add_foreign_key "webauthn_credentials", "users"
  971. create_view "instances", materialized: true, sql_definition: <<-SQL
  972. WITH domain_counts(domain, accounts_count) AS (
  973. SELECT accounts.domain,
  974. count(*) AS accounts_count
  975. FROM accounts
  976. WHERE (accounts.domain IS NOT NULL)
  977. GROUP BY accounts.domain
  978. )
  979. SELECT domain_counts.domain,
  980. domain_counts.accounts_count
  981. FROM domain_counts
  982. UNION
  983. SELECT domain_blocks.domain,
  984. COALESCE(domain_counts.accounts_count, (0)::bigint) AS accounts_count
  985. FROM (domain_blocks
  986. LEFT JOIN domain_counts ON (((domain_counts.domain)::text = (domain_blocks.domain)::text)))
  987. UNION
  988. SELECT domain_allows.domain,
  989. COALESCE(domain_counts.accounts_count, (0)::bigint) AS accounts_count
  990. FROM (domain_allows
  991. LEFT JOIN domain_counts ON (((domain_counts.domain)::text = (domain_allows.domain)::text)));
  992. SQL
  993. add_index "instances", ["domain"], name: "index_instances_on_domain", unique: true
  994. end