schema.rb 73 KB

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