schema.rb 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449
  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_10_07_071624) 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.datetime "sensitized_at", precision: nil
  182. t.integer "suspension_origin"
  183. t.boolean "trendable"
  184. t.datetime "reviewed_at", precision: nil
  185. t.datetime "requested_review_at", precision: nil
  186. t.boolean "indexable", default: false, null: false
  187. t.string "attribution_domains", default: [], array: true
  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 "domain_allows", force: :cascade do |t|
  380. t.string "domain", default: "", null: false
  381. t.datetime "created_at", precision: nil, null: false
  382. t.datetime "updated_at", precision: nil, null: false
  383. t.index ["domain"], name: "index_domain_allows_on_domain", unique: true
  384. end
  385. create_table "domain_blocks", force: :cascade do |t|
  386. t.string "domain", default: "", null: false
  387. t.datetime "created_at", precision: nil, null: false
  388. t.datetime "updated_at", precision: nil, null: false
  389. t.integer "severity", default: 0
  390. t.boolean "reject_media", default: false, null: false
  391. t.boolean "reject_reports", default: false, null: false
  392. t.text "private_comment"
  393. t.text "public_comment"
  394. t.boolean "obfuscate", default: false, null: false
  395. t.index ["domain"], name: "index_domain_blocks_on_domain", unique: true
  396. end
  397. create_table "email_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.bigint "parent_id"
  402. t.boolean "allow_with_approval", default: false, null: false
  403. t.index ["domain"], name: "index_email_domain_blocks_on_domain", unique: true
  404. end
  405. create_table "favourites", force: :cascade do |t|
  406. t.datetime "created_at", precision: nil, null: false
  407. t.datetime "updated_at", precision: nil, null: false
  408. t.bigint "account_id", null: false
  409. t.bigint "status_id", null: false
  410. t.index ["account_id", "id"], name: "index_favourites_on_account_id_and_id"
  411. t.index ["account_id", "status_id"], name: "index_favourites_on_account_id_and_status_id", unique: true
  412. t.index ["status_id"], name: "index_favourites_on_status_id"
  413. end
  414. create_table "featured_tags", force: :cascade do |t|
  415. t.bigint "account_id", null: false
  416. t.bigint "tag_id", null: false
  417. t.bigint "statuses_count", default: 0, null: false
  418. t.datetime "last_status_at", precision: nil
  419. t.datetime "created_at", precision: nil, null: false
  420. t.datetime "updated_at", precision: nil, null: false
  421. t.string "name"
  422. t.index ["account_id", "tag_id"], name: "index_featured_tags_on_account_id_and_tag_id", unique: true
  423. t.index ["tag_id"], name: "index_featured_tags_on_tag_id"
  424. end
  425. create_table "follow_recommendation_mutes", force: :cascade do |t|
  426. t.bigint "account_id", null: false
  427. t.bigint "target_account_id", null: false
  428. t.datetime "created_at", null: false
  429. t.datetime "updated_at", null: false
  430. t.index ["account_id", "target_account_id"], name: "idx_on_account_id_target_account_id_a8c8ddf44e", unique: true
  431. t.index ["target_account_id"], name: "index_follow_recommendation_mutes_on_target_account_id"
  432. end
  433. create_table "follow_recommendation_suppressions", force: :cascade do |t|
  434. t.bigint "account_id", null: false
  435. t.datetime "created_at", null: false
  436. t.datetime "updated_at", null: false
  437. t.index ["account_id"], name: "index_follow_recommendation_suppressions_on_account_id", unique: true
  438. end
  439. create_table "follow_requests", force: :cascade do |t|
  440. t.datetime "created_at", precision: nil, null: false
  441. t.datetime "updated_at", precision: nil, null: false
  442. t.bigint "account_id", null: false
  443. t.bigint "target_account_id", null: false
  444. t.boolean "show_reblogs", default: true, null: false
  445. t.string "uri"
  446. t.boolean "notify", default: false, null: false
  447. t.string "languages", array: true
  448. t.index ["account_id", "target_account_id"], name: "index_follow_requests_on_account_id_and_target_account_id", unique: true
  449. end
  450. create_table "follows", force: :cascade do |t|
  451. t.datetime "created_at", precision: nil, null: false
  452. t.datetime "updated_at", precision: nil, null: false
  453. t.bigint "account_id", null: false
  454. t.bigint "target_account_id", null: false
  455. t.boolean "show_reblogs", default: true, null: false
  456. t.string "uri"
  457. t.boolean "notify", default: false, null: false
  458. t.string "languages", array: true
  459. t.index ["account_id", "target_account_id"], name: "index_follows_on_account_id_and_target_account_id", unique: true
  460. t.index ["target_account_id"], name: "index_follows_on_target_account_id"
  461. end
  462. create_table "generated_annual_reports", force: :cascade do |t|
  463. t.bigint "account_id", null: false
  464. t.integer "year", null: false
  465. t.jsonb "data", null: false
  466. t.integer "schema_version", null: false
  467. t.datetime "viewed_at"
  468. t.datetime "created_at", null: false
  469. t.datetime "updated_at", null: false
  470. t.index ["account_id", "year"], name: "index_generated_annual_reports_on_account_id_and_year", unique: true
  471. end
  472. create_table "identities", force: :cascade do |t|
  473. t.string "provider", default: "", null: false
  474. t.string "uid", default: "", null: false
  475. t.datetime "created_at", precision: nil, null: false
  476. t.datetime "updated_at", precision: nil, null: false
  477. t.bigint "user_id"
  478. t.index ["uid", "provider"], name: "index_identities_on_uid_and_provider", unique: true
  479. t.index ["user_id"], name: "index_identities_on_user_id"
  480. end
  481. create_table "imports", force: :cascade do |t|
  482. t.integer "type", null: false
  483. t.boolean "approved", default: false, null: false
  484. t.datetime "created_at", precision: nil, null: false
  485. t.datetime "updated_at", precision: nil, null: false
  486. t.string "data_file_name"
  487. t.string "data_content_type"
  488. t.integer "data_file_size"
  489. t.datetime "data_updated_at", precision: nil
  490. t.bigint "account_id", null: false
  491. t.boolean "overwrite", default: false, null: false
  492. end
  493. create_table "invites", force: :cascade do |t|
  494. t.bigint "user_id", null: false
  495. t.string "code", default: "", null: false
  496. t.datetime "expires_at", precision: nil
  497. t.integer "max_uses"
  498. t.integer "uses", default: 0, null: false
  499. t.datetime "created_at", precision: nil, null: false
  500. t.datetime "updated_at", precision: nil, null: false
  501. t.boolean "autofollow", default: false, null: false
  502. t.text "comment"
  503. t.index ["code"], name: "index_invites_on_code", unique: true
  504. t.index ["user_id"], name: "index_invites_on_user_id"
  505. end
  506. create_table "ip_blocks", force: :cascade do |t|
  507. t.inet "ip", default: "0.0.0.0", null: false
  508. t.integer "severity", default: 0, null: false
  509. t.datetime "expires_at", precision: nil
  510. t.text "comment", default: "", null: false
  511. t.datetime "created_at", precision: nil, null: false
  512. t.datetime "updated_at", precision: nil, null: false
  513. t.index ["ip"], name: "index_ip_blocks_on_ip", unique: true
  514. end
  515. create_table "list_accounts", force: :cascade do |t|
  516. t.bigint "list_id", null: false
  517. t.bigint "account_id", null: false
  518. t.bigint "follow_id"
  519. t.bigint "follow_request_id"
  520. t.index ["account_id", "list_id"], name: "index_list_accounts_on_account_id_and_list_id", unique: true
  521. t.index ["follow_id"], name: "index_list_accounts_on_follow_id", where: "(follow_id IS NOT NULL)"
  522. t.index ["follow_request_id"], name: "index_list_accounts_on_follow_request_id", where: "(follow_request_id IS NOT NULL)"
  523. t.index ["list_id", "account_id"], name: "index_list_accounts_on_list_id_and_account_id"
  524. end
  525. create_table "lists", force: :cascade do |t|
  526. t.bigint "account_id", null: false
  527. t.string "title", default: "", null: false
  528. t.datetime "created_at", precision: nil, null: false
  529. t.datetime "updated_at", precision: nil, null: false
  530. t.integer "replies_policy", default: 0, null: false
  531. t.boolean "exclusive", default: false, null: false
  532. t.index ["account_id"], name: "index_lists_on_account_id"
  533. end
  534. create_table "login_activities", force: :cascade do |t|
  535. t.bigint "user_id", null: false
  536. t.string "authentication_method"
  537. t.string "provider"
  538. t.boolean "success"
  539. t.string "failure_reason"
  540. t.inet "ip"
  541. t.string "user_agent"
  542. t.datetime "created_at", precision: nil
  543. t.index ["user_id"], name: "index_login_activities_on_user_id"
  544. end
  545. create_table "markers", force: :cascade do |t|
  546. t.bigint "user_id"
  547. t.string "timeline", default: "", null: false
  548. t.bigint "last_read_id", default: 0, null: false
  549. t.integer "lock_version", default: 0, null: false
  550. t.datetime "created_at", precision: nil, null: false
  551. t.datetime "updated_at", precision: nil, null: false
  552. t.index ["user_id", "timeline"], name: "index_markers_on_user_id_and_timeline", unique: true
  553. end
  554. create_table "media_attachments", id: :bigint, default: -> { "timestamp_id('media_attachments'::text)" }, force: :cascade do |t|
  555. t.bigint "status_id"
  556. t.string "file_file_name"
  557. t.string "file_content_type"
  558. t.integer "file_file_size"
  559. t.datetime "file_updated_at", precision: nil
  560. t.string "remote_url", default: "", null: false
  561. t.datetime "created_at", precision: nil, null: false
  562. t.datetime "updated_at", precision: nil, null: false
  563. t.string "shortcode"
  564. t.integer "type", default: 0, null: false
  565. t.json "file_meta"
  566. t.bigint "account_id"
  567. t.text "description"
  568. t.bigint "scheduled_status_id"
  569. t.string "blurhash"
  570. t.integer "processing"
  571. t.integer "file_storage_schema_version"
  572. t.string "thumbnail_file_name"
  573. t.string "thumbnail_content_type"
  574. t.integer "thumbnail_file_size"
  575. t.datetime "thumbnail_updated_at", precision: nil
  576. t.string "thumbnail_remote_url"
  577. t.index ["account_id", "status_id"], name: "index_media_attachments_on_account_id_and_status_id", order: { status_id: :desc }
  578. t.index ["scheduled_status_id"], name: "index_media_attachments_on_scheduled_status_id", where: "(scheduled_status_id IS NOT NULL)"
  579. t.index ["shortcode"], name: "index_media_attachments_on_shortcode", unique: true, opclass: :text_pattern_ops, where: "(shortcode IS NOT NULL)"
  580. t.index ["status_id"], name: "index_media_attachments_on_status_id"
  581. end
  582. create_table "mentions", force: :cascade do |t|
  583. t.bigint "status_id", null: false
  584. t.datetime "created_at", precision: nil, null: false
  585. t.datetime "updated_at", precision: nil, null: false
  586. t.bigint "account_id", null: false
  587. t.boolean "silent", default: false, null: false
  588. t.index ["account_id", "status_id"], name: "index_mentions_on_account_id_and_status_id", unique: true
  589. t.index ["status_id"], name: "index_mentions_on_status_id"
  590. end
  591. create_table "mutes", force: :cascade do |t|
  592. t.datetime "created_at", precision: nil, null: false
  593. t.datetime "updated_at", precision: nil, null: false
  594. t.boolean "hide_notifications", default: true, null: false
  595. t.bigint "account_id", null: false
  596. t.bigint "target_account_id", null: false
  597. t.datetime "expires_at", precision: nil
  598. t.index ["account_id", "target_account_id"], name: "index_mutes_on_account_id_and_target_account_id", unique: true
  599. t.index ["target_account_id"], name: "index_mutes_on_target_account_id"
  600. end
  601. create_table "notification_permissions", force: :cascade do |t|
  602. t.bigint "account_id", null: false
  603. t.bigint "from_account_id", null: false
  604. t.datetime "created_at", null: false
  605. t.datetime "updated_at", null: false
  606. t.index ["account_id"], name: "index_notification_permissions_on_account_id"
  607. t.index ["from_account_id"], name: "index_notification_permissions_on_from_account_id"
  608. end
  609. create_table "notification_policies", force: :cascade do |t|
  610. t.bigint "account_id", null: false
  611. t.datetime "created_at", null: false
  612. t.datetime "updated_at", null: false
  613. t.integer "for_not_following", default: 0, null: false
  614. t.integer "for_not_followers", default: 0, null: false
  615. t.integer "for_new_accounts", default: 0, null: false
  616. t.integer "for_private_mentions", default: 1, null: false
  617. t.integer "for_limited_accounts", default: 1, null: false
  618. t.index ["account_id"], name: "index_notification_policies_on_account_id", unique: true
  619. end
  620. create_table "notification_requests", id: :bigint, default: -> { "timestamp_id('notification_requests'::text)" }, force: :cascade do |t|
  621. t.bigint "account_id", null: false
  622. t.bigint "from_account_id", null: false
  623. t.bigint "last_status_id"
  624. t.bigint "notifications_count", default: 0, null: false
  625. t.datetime "created_at", null: false
  626. t.datetime "updated_at", null: false
  627. t.index ["account_id", "from_account_id"], name: "index_notification_requests_on_account_id_and_from_account_id", unique: true
  628. t.index ["from_account_id"], name: "index_notification_requests_on_from_account_id"
  629. t.index ["last_status_id"], name: "index_notification_requests_on_last_status_id"
  630. end
  631. create_table "notifications", force: :cascade do |t|
  632. t.bigint "activity_id", null: false
  633. t.string "activity_type", null: false
  634. t.datetime "created_at", precision: nil, null: false
  635. t.datetime "updated_at", precision: nil, null: false
  636. t.bigint "account_id", null: false
  637. t.bigint "from_account_id", null: false
  638. t.string "type"
  639. t.boolean "filtered", default: false, null: false
  640. t.string "group_key"
  641. t.index ["account_id", "group_key"], name: "index_notifications_on_account_id_and_group_key", where: "(group_key IS NOT NULL)"
  642. t.index ["account_id", "id", "type"], name: "index_notifications_on_account_id_and_id_and_type", order: { id: :desc }
  643. t.index ["account_id", "id", "type"], name: "index_notifications_on_filtered", order: { id: :desc }, where: "(filtered = false)"
  644. t.index ["activity_id", "activity_type"], name: "index_notifications_on_activity_id_and_activity_type"
  645. t.index ["from_account_id"], name: "index_notifications_on_from_account_id"
  646. end
  647. create_table "oauth_access_grants", force: :cascade do |t|
  648. t.string "token", null: false
  649. t.integer "expires_in", null: false
  650. t.text "redirect_uri", null: false
  651. t.datetime "created_at", precision: nil, null: false
  652. t.datetime "revoked_at", precision: nil
  653. t.string "scopes"
  654. t.bigint "application_id", null: false
  655. t.bigint "resource_owner_id", null: false
  656. t.string "code_challenge"
  657. t.string "code_challenge_method"
  658. t.index ["resource_owner_id"], name: "index_oauth_access_grants_on_resource_owner_id"
  659. t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true
  660. end
  661. create_table "oauth_access_tokens", force: :cascade do |t|
  662. t.string "token", null: false
  663. t.string "refresh_token"
  664. t.integer "expires_in"
  665. t.datetime "revoked_at", precision: nil
  666. t.datetime "created_at", precision: nil, null: false
  667. t.string "scopes"
  668. t.bigint "application_id"
  669. t.bigint "resource_owner_id"
  670. t.datetime "last_used_at", precision: nil
  671. t.inet "last_used_ip"
  672. t.index ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true, opclass: :text_pattern_ops, where: "(refresh_token IS NOT NULL)"
  673. t.index ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id", where: "(resource_owner_id IS NOT NULL)"
  674. t.index ["token"], name: "index_oauth_access_tokens_on_token", unique: true
  675. end
  676. create_table "oauth_applications", force: :cascade do |t|
  677. t.string "name", null: false
  678. t.string "uid", null: false
  679. t.string "secret", null: false
  680. t.text "redirect_uri", null: false
  681. t.string "scopes", default: "", null: false
  682. t.datetime "created_at", precision: nil
  683. t.datetime "updated_at", precision: nil
  684. t.boolean "superapp", default: false, null: false
  685. t.string "website"
  686. t.string "owner_type"
  687. t.bigint "owner_id"
  688. t.boolean "confidential", default: true, null: false
  689. t.index ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type"
  690. t.index ["superapp"], name: "index_oauth_applications_on_superapp", where: "(superapp = true)"
  691. t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true
  692. end
  693. create_table "pghero_space_stats", force: :cascade do |t|
  694. t.text "database"
  695. t.text "schema"
  696. t.text "relation"
  697. t.bigint "size"
  698. t.datetime "captured_at", precision: nil
  699. t.index ["database", "captured_at"], name: "index_pghero_space_stats_on_database_and_captured_at"
  700. end
  701. create_table "poll_votes", force: :cascade do |t|
  702. t.bigint "account_id"
  703. t.bigint "poll_id"
  704. t.integer "choice", default: 0, null: false
  705. t.datetime "created_at", precision: nil, null: false
  706. t.datetime "updated_at", precision: nil, null: false
  707. t.string "uri"
  708. t.index ["account_id"], name: "index_poll_votes_on_account_id"
  709. t.index ["poll_id"], name: "index_poll_votes_on_poll_id"
  710. end
  711. create_table "polls", force: :cascade do |t|
  712. t.bigint "account_id"
  713. t.bigint "status_id"
  714. t.datetime "expires_at", precision: nil
  715. t.string "options", default: [], null: false, array: true
  716. t.bigint "cached_tallies", default: [], null: false, array: true
  717. t.boolean "multiple", default: false, null: false
  718. t.boolean "hide_totals", default: false, null: false
  719. t.bigint "votes_count", default: 0, null: false
  720. t.datetime "last_fetched_at", precision: nil
  721. t.datetime "created_at", precision: nil, null: false
  722. t.datetime "updated_at", precision: nil, null: false
  723. t.integer "lock_version", default: 0, null: false
  724. t.bigint "voters_count"
  725. t.index ["account_id"], name: "index_polls_on_account_id"
  726. t.index ["status_id"], name: "index_polls_on_status_id"
  727. end
  728. create_table "preview_card_providers", force: :cascade do |t|
  729. t.string "domain", default: "", null: false
  730. t.string "icon_file_name"
  731. t.string "icon_content_type"
  732. t.bigint "icon_file_size"
  733. t.datetime "icon_updated_at", precision: nil
  734. t.boolean "trendable"
  735. t.datetime "reviewed_at", precision: nil
  736. t.datetime "requested_review_at", precision: nil
  737. t.datetime "created_at", null: false
  738. t.datetime "updated_at", null: false
  739. t.index ["domain"], name: "index_preview_card_providers_on_domain", unique: true
  740. end
  741. create_table "preview_card_trends", force: :cascade do |t|
  742. t.bigint "preview_card_id", null: false
  743. t.float "score", default: 0.0, null: false
  744. t.integer "rank", default: 0, null: false
  745. t.boolean "allowed", default: false, null: false
  746. t.string "language"
  747. t.index ["preview_card_id"], name: "index_preview_card_trends_on_preview_card_id", unique: true
  748. end
  749. create_table "preview_cards", force: :cascade do |t|
  750. t.string "url", default: "", null: false
  751. t.string "title", default: "", null: false
  752. t.string "description", default: "", null: false
  753. t.string "image_file_name"
  754. t.string "image_content_type"
  755. t.integer "image_file_size"
  756. t.datetime "image_updated_at", precision: nil
  757. t.integer "type", default: 0, null: false
  758. t.text "html", default: "", null: false
  759. t.string "author_name", default: "", null: false
  760. t.string "author_url", default: "", null: false
  761. t.string "provider_name", default: "", null: false
  762. t.string "provider_url", default: "", null: false
  763. t.integer "width", default: 0, null: false
  764. t.integer "height", default: 0, null: false
  765. t.datetime "created_at", precision: nil, null: false
  766. t.datetime "updated_at", precision: nil, null: false
  767. t.string "embed_url", default: "", null: false
  768. t.integer "image_storage_schema_version"
  769. t.string "blurhash"
  770. t.string "language"
  771. t.float "max_score"
  772. t.datetime "max_score_at", precision: nil
  773. t.boolean "trendable"
  774. t.integer "link_type"
  775. t.datetime "published_at"
  776. t.string "image_description", default: "", null: false
  777. t.bigint "author_account_id"
  778. t.index ["author_account_id"], name: "index_preview_cards_on_author_account_id", where: "(author_account_id IS NOT NULL)"
  779. t.index ["url"], name: "index_preview_cards_on_url", unique: true
  780. end
  781. create_table "preview_cards_statuses", primary_key: ["status_id", "preview_card_id"], force: :cascade do |t|
  782. t.bigint "preview_card_id", null: false
  783. t.bigint "status_id", null: false
  784. t.string "url"
  785. end
  786. create_table "relationship_severance_events", force: :cascade do |t|
  787. t.integer "type", null: false
  788. t.string "target_name", null: false
  789. t.boolean "purged", default: false, null: false
  790. t.datetime "created_at", null: false
  791. t.datetime "updated_at", null: false
  792. t.index ["type", "target_name"], name: "index_relationship_severance_events_on_type_and_target_name"
  793. end
  794. create_table "relays", force: :cascade do |t|
  795. t.string "inbox_url", default: "", null: false
  796. t.string "follow_activity_id"
  797. t.datetime "created_at", precision: nil, null: false
  798. t.datetime "updated_at", precision: nil, null: false
  799. t.integer "state", default: 0, null: false
  800. end
  801. create_table "report_notes", force: :cascade do |t|
  802. t.text "content", null: false
  803. t.bigint "report_id", null: false
  804. t.bigint "account_id", null: false
  805. t.datetime "created_at", precision: nil, null: false
  806. t.datetime "updated_at", precision: nil, null: false
  807. t.index ["account_id"], name: "index_report_notes_on_account_id"
  808. t.index ["report_id"], name: "index_report_notes_on_report_id"
  809. end
  810. create_table "reports", force: :cascade do |t|
  811. t.bigint "status_ids", default: [], null: false, array: true
  812. t.text "comment", default: "", null: false
  813. t.datetime "created_at", precision: nil, null: false
  814. t.datetime "updated_at", precision: nil, null: false
  815. t.bigint "account_id", null: false
  816. t.bigint "action_taken_by_account_id"
  817. t.bigint "target_account_id", null: false
  818. t.bigint "assigned_account_id"
  819. t.string "uri"
  820. t.boolean "forwarded"
  821. t.integer "category", default: 0, null: false
  822. t.datetime "action_taken_at", precision: nil
  823. t.bigint "rule_ids", array: true
  824. t.bigint "application_id"
  825. t.index ["account_id"], name: "index_reports_on_account_id"
  826. 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)"
  827. t.index ["assigned_account_id"], name: "index_reports_on_assigned_account_id", where: "(assigned_account_id IS NOT NULL)"
  828. t.index ["target_account_id"], name: "index_reports_on_target_account_id"
  829. end
  830. create_table "rules", force: :cascade do |t|
  831. t.integer "priority", default: 0, null: false
  832. t.datetime "deleted_at", precision: nil
  833. t.text "text", default: "", null: false
  834. t.datetime "created_at", precision: nil, null: false
  835. t.datetime "updated_at", precision: nil, null: false
  836. t.text "hint", default: "", null: false
  837. end
  838. create_table "scheduled_statuses", force: :cascade do |t|
  839. t.bigint "account_id"
  840. t.datetime "scheduled_at", precision: nil
  841. t.jsonb "params"
  842. t.index ["account_id"], name: "index_scheduled_statuses_on_account_id"
  843. t.index ["scheduled_at"], name: "index_scheduled_statuses_on_scheduled_at"
  844. end
  845. create_table "session_activations", force: :cascade do |t|
  846. t.string "session_id", null: false
  847. t.datetime "created_at", precision: nil, null: false
  848. t.datetime "updated_at", precision: nil, null: false
  849. t.string "user_agent", default: "", null: false
  850. t.inet "ip"
  851. t.bigint "access_token_id"
  852. t.bigint "user_id", null: false
  853. t.bigint "web_push_subscription_id"
  854. t.index ["access_token_id"], name: "index_session_activations_on_access_token_id"
  855. t.index ["session_id"], name: "index_session_activations_on_session_id", unique: true
  856. t.index ["user_id"], name: "index_session_activations_on_user_id"
  857. end
  858. create_table "settings", force: :cascade do |t|
  859. t.string "var", null: false
  860. t.text "value"
  861. t.string "thing_type"
  862. t.datetime "created_at", precision: nil
  863. t.datetime "updated_at", precision: nil
  864. t.bigint "thing_id"
  865. t.index ["thing_type", "thing_id", "var"], name: "index_settings_on_thing_type_and_thing_id_and_var", unique: true
  866. end
  867. create_table "severed_relationships", force: :cascade do |t|
  868. t.bigint "relationship_severance_event_id", null: false
  869. t.bigint "local_account_id", null: false
  870. t.bigint "remote_account_id", null: false
  871. t.integer "direction", null: false
  872. t.boolean "show_reblogs"
  873. t.boolean "notify"
  874. t.string "languages", array: true
  875. t.datetime "created_at", null: false
  876. t.datetime "updated_at", null: false
  877. t.index ["local_account_id", "relationship_severance_event_id"], name: "index_severed_relationships_on_local_account_and_event"
  878. t.index ["relationship_severance_event_id", "local_account_id", "direction", "remote_account_id"], name: "index_severed_relationships_on_unique_tuples", unique: true
  879. t.index ["remote_account_id"], name: "index_severed_relationships_on_remote_account_id"
  880. end
  881. create_table "site_uploads", force: :cascade do |t|
  882. t.string "var", default: "", null: false
  883. t.string "file_file_name"
  884. t.string "file_content_type"
  885. t.integer "file_file_size"
  886. t.datetime "file_updated_at", precision: nil
  887. t.json "meta"
  888. t.datetime "created_at", precision: nil, null: false
  889. t.datetime "updated_at", precision: nil, null: false
  890. t.string "blurhash"
  891. t.index ["var"], name: "index_site_uploads_on_var", unique: true
  892. end
  893. create_table "software_updates", force: :cascade do |t|
  894. t.string "version", null: false
  895. t.boolean "urgent", default: false, null: false
  896. t.integer "type", default: 0, null: false
  897. t.string "release_notes", default: "", null: false
  898. t.datetime "created_at", null: false
  899. t.datetime "updated_at", null: false
  900. t.index ["version"], name: "index_software_updates_on_version", unique: true
  901. end
  902. create_table "status_edits", force: :cascade do |t|
  903. t.bigint "status_id", null: false
  904. t.bigint "account_id"
  905. t.text "text", default: "", null: false
  906. t.text "spoiler_text", default: "", null: false
  907. t.datetime "created_at", null: false
  908. t.datetime "updated_at", null: false
  909. t.bigint "ordered_media_attachment_ids", array: true
  910. t.text "media_descriptions", array: true
  911. t.string "poll_options", array: true
  912. t.boolean "sensitive"
  913. t.index ["account_id"], name: "index_status_edits_on_account_id"
  914. t.index ["status_id"], name: "index_status_edits_on_status_id"
  915. end
  916. create_table "status_pins", force: :cascade do |t|
  917. t.bigint "account_id", null: false
  918. t.bigint "status_id", null: false
  919. t.datetime "created_at", precision: nil, null: false
  920. t.datetime "updated_at", precision: nil, null: false
  921. t.index ["account_id", "status_id"], name: "index_status_pins_on_account_id_and_status_id", unique: true
  922. t.index ["status_id"], name: "index_status_pins_on_status_id"
  923. end
  924. create_table "status_stats", force: :cascade do |t|
  925. t.bigint "status_id", null: false
  926. t.bigint "replies_count", default: 0, null: false
  927. t.bigint "reblogs_count", default: 0, null: false
  928. t.bigint "favourites_count", default: 0, null: false
  929. t.datetime "created_at", precision: nil, null: false
  930. t.datetime "updated_at", precision: nil, null: false
  931. t.index ["status_id"], name: "index_status_stats_on_status_id", unique: true
  932. end
  933. create_table "status_trends", force: :cascade do |t|
  934. t.bigint "status_id", null: false
  935. t.bigint "account_id", null: false
  936. t.float "score", default: 0.0, null: false
  937. t.integer "rank", default: 0, null: false
  938. t.boolean "allowed", default: false, null: false
  939. t.string "language"
  940. t.index ["account_id"], name: "index_status_trends_on_account_id"
  941. t.index ["status_id"], name: "index_status_trends_on_status_id", unique: true
  942. end
  943. create_table "statuses", id: :bigint, default: -> { "timestamp_id('statuses'::text)" }, force: :cascade do |t|
  944. t.string "uri"
  945. t.text "text", default: "", null: false
  946. t.datetime "created_at", precision: nil, null: false
  947. t.datetime "updated_at", precision: nil, null: false
  948. t.bigint "in_reply_to_id"
  949. t.bigint "reblog_of_id"
  950. t.string "url"
  951. t.boolean "sensitive", default: false, null: false
  952. t.integer "visibility", default: 0, null: false
  953. t.text "spoiler_text", default: "", null: false
  954. t.boolean "reply", default: false, null: false
  955. t.string "language"
  956. t.bigint "conversation_id"
  957. t.boolean "local"
  958. t.bigint "account_id", null: false
  959. t.bigint "application_id"
  960. t.bigint "in_reply_to_account_id"
  961. t.bigint "poll_id"
  962. t.datetime "deleted_at", precision: nil
  963. t.datetime "edited_at", precision: nil
  964. t.boolean "trendable"
  965. t.bigint "ordered_media_attachment_ids", array: true
  966. t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20190820", order: { id: :desc }, where: "(deleted_at IS NULL)"
  967. t.index ["account_id"], name: "index_statuses_on_account_id"
  968. t.index ["deleted_at"], name: "index_statuses_on_deleted_at", where: "(deleted_at IS NOT NULL)"
  969. 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)))"
  970. 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)))"
  971. 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)"
  972. t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id", where: "(in_reply_to_id IS NOT NULL)"
  973. t.index ["reblog_of_id", "account_id"], name: "index_statuses_on_reblog_of_id_and_account_id"
  974. t.index ["uri"], name: "index_statuses_on_uri", unique: true, opclass: :text_pattern_ops, where: "(uri IS NOT NULL)"
  975. end
  976. create_table "statuses_tags", primary_key: ["tag_id", "status_id"], force: :cascade do |t|
  977. t.bigint "status_id", null: false
  978. t.bigint "tag_id", null: false
  979. t.index ["status_id"], name: "index_statuses_tags_on_status_id"
  980. end
  981. create_table "tag_follows", force: :cascade do |t|
  982. t.bigint "tag_id", null: false
  983. t.bigint "account_id", null: false
  984. t.datetime "created_at", null: false
  985. t.datetime "updated_at", null: false
  986. t.index ["account_id", "tag_id"], name: "index_tag_follows_on_account_id_and_tag_id", unique: true
  987. t.index ["tag_id"], name: "index_tag_follows_on_tag_id"
  988. end
  989. create_table "tags", force: :cascade do |t|
  990. t.string "name", default: "", null: false
  991. t.datetime "created_at", precision: nil, null: false
  992. t.datetime "updated_at", precision: nil, null: false
  993. t.boolean "usable"
  994. t.boolean "trendable"
  995. t.boolean "listable"
  996. t.datetime "reviewed_at", precision: nil
  997. t.datetime "requested_review_at", precision: nil
  998. t.datetime "last_status_at", precision: nil
  999. t.float "max_score"
  1000. t.datetime "max_score_at", precision: nil
  1001. t.string "display_name"
  1002. t.index "lower((name)::text) text_pattern_ops", name: "index_tags_on_name_lower_btree", unique: true
  1003. end
  1004. create_table "tombstones", force: :cascade do |t|
  1005. t.bigint "account_id"
  1006. t.string "uri", null: false
  1007. t.datetime "created_at", precision: nil, null: false
  1008. t.datetime "updated_at", precision: nil, null: false
  1009. t.boolean "by_moderator"
  1010. t.index ["account_id"], name: "index_tombstones_on_account_id"
  1011. t.index ["uri"], name: "index_tombstones_on_uri"
  1012. end
  1013. create_table "unavailable_domains", force: :cascade do |t|
  1014. t.string "domain", default: "", null: false
  1015. t.datetime "created_at", precision: nil, null: false
  1016. t.datetime "updated_at", precision: nil, null: false
  1017. t.index ["domain"], name: "index_unavailable_domains_on_domain", unique: true
  1018. end
  1019. create_table "user_invite_requests", force: :cascade do |t|
  1020. t.bigint "user_id"
  1021. t.text "text"
  1022. t.datetime "created_at", precision: nil, null: false
  1023. t.datetime "updated_at", precision: nil, null: false
  1024. t.index ["user_id"], name: "index_user_invite_requests_on_user_id"
  1025. end
  1026. create_table "user_roles", force: :cascade do |t|
  1027. t.string "name", default: "", null: false
  1028. t.string "color", default: "", null: false
  1029. t.integer "position", default: 0, null: false
  1030. t.bigint "permissions", default: 0, null: false
  1031. t.boolean "highlighted", default: false, null: false
  1032. t.datetime "created_at", null: false
  1033. t.datetime "updated_at", null: false
  1034. end
  1035. create_table "users", force: :cascade do |t|
  1036. t.string "email", default: "", null: false
  1037. t.datetime "created_at", precision: nil, null: false
  1038. t.datetime "updated_at", precision: nil, null: false
  1039. t.string "encrypted_password", default: "", null: false
  1040. t.string "reset_password_token"
  1041. t.datetime "reset_password_sent_at", precision: nil
  1042. t.integer "sign_in_count", default: 0, null: false
  1043. t.datetime "current_sign_in_at", precision: nil
  1044. t.datetime "last_sign_in_at", precision: nil
  1045. t.string "confirmation_token"
  1046. t.datetime "confirmed_at", precision: nil
  1047. t.datetime "confirmation_sent_at", precision: nil
  1048. t.string "unconfirmed_email"
  1049. t.string "locale"
  1050. t.string "encrypted_otp_secret"
  1051. t.string "encrypted_otp_secret_iv"
  1052. t.string "encrypted_otp_secret_salt"
  1053. t.integer "consumed_timestep"
  1054. t.boolean "otp_required_for_login", default: false, null: false
  1055. t.datetime "last_emailed_at", precision: nil
  1056. t.string "otp_backup_codes", array: true
  1057. t.bigint "account_id", null: false
  1058. t.boolean "disabled", default: false, null: false
  1059. t.bigint "invite_id"
  1060. t.string "chosen_languages", array: true
  1061. t.bigint "created_by_application_id"
  1062. t.boolean "approved", default: true, null: false
  1063. t.string "sign_in_token"
  1064. t.datetime "sign_in_token_sent_at", precision: nil
  1065. t.string "webauthn_id"
  1066. t.inet "sign_up_ip"
  1067. t.boolean "skip_sign_in_token"
  1068. t.bigint "role_id"
  1069. t.text "settings"
  1070. t.string "time_zone"
  1071. t.string "otp_secret"
  1072. t.index ["account_id"], name: "index_users_on_account_id"
  1073. t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
  1074. t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id", where: "(created_by_application_id IS NOT NULL)"
  1075. t.index ["email"], name: "index_users_on_email", unique: true
  1076. 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)"
  1077. t.index ["role_id"], name: "index_users_on_role_id", where: "(role_id IS NOT NULL)"
  1078. t.index ["unconfirmed_email"], name: "index_users_on_unconfirmed_email", where: "(unconfirmed_email IS NOT NULL)"
  1079. end
  1080. create_table "web_push_subscriptions", force: :cascade do |t|
  1081. t.string "endpoint", null: false
  1082. t.string "key_p256dh", null: false
  1083. t.string "key_auth", null: false
  1084. t.json "data"
  1085. t.datetime "created_at", precision: nil, null: false
  1086. t.datetime "updated_at", precision: nil, null: false
  1087. t.bigint "access_token_id"
  1088. t.bigint "user_id"
  1089. t.index ["access_token_id"], name: "index_web_push_subscriptions_on_access_token_id", where: "(access_token_id IS NOT NULL)"
  1090. t.index ["user_id"], name: "index_web_push_subscriptions_on_user_id"
  1091. end
  1092. create_table "web_settings", force: :cascade do |t|
  1093. t.json "data"
  1094. t.datetime "created_at", precision: nil, null: false
  1095. t.datetime "updated_at", precision: nil, null: false
  1096. t.bigint "user_id", null: false
  1097. t.index ["user_id"], name: "index_web_settings_on_user_id", unique: true
  1098. end
  1099. create_table "webauthn_credentials", force: :cascade do |t|
  1100. t.string "external_id", null: false
  1101. t.string "public_key", null: false
  1102. t.string "nickname", null: false
  1103. t.bigint "sign_count", default: 0, null: false
  1104. t.bigint "user_id"
  1105. t.datetime "created_at", precision: nil, null: false
  1106. t.datetime "updated_at", precision: nil, null: false
  1107. t.index ["external_id"], name: "index_webauthn_credentials_on_external_id", unique: true
  1108. t.index ["user_id", "nickname"], name: "index_webauthn_credentials_on_user_id_and_nickname", unique: true
  1109. t.index ["user_id"], name: "index_webauthn_credentials_on_user_id"
  1110. end
  1111. create_table "webhooks", force: :cascade do |t|
  1112. t.string "url", null: false
  1113. t.string "events", default: [], null: false, array: true
  1114. t.string "secret", default: "", null: false
  1115. t.boolean "enabled", default: true, null: false
  1116. t.datetime "created_at", null: false
  1117. t.datetime "updated_at", null: false
  1118. t.text "template"
  1119. t.index ["url"], name: "index_webhooks_on_url", unique: true
  1120. end
  1121. add_foreign_key "account_aliases", "accounts", on_delete: :cascade
  1122. add_foreign_key "account_conversations", "accounts", on_delete: :cascade
  1123. add_foreign_key "account_conversations", "conversations", on_delete: :cascade
  1124. add_foreign_key "account_deletion_requests", "accounts", on_delete: :cascade
  1125. add_foreign_key "account_domain_blocks", "accounts", name: "fk_206c6029bd", on_delete: :cascade
  1126. add_foreign_key "account_migrations", "accounts", column: "target_account_id", on_delete: :nullify
  1127. add_foreign_key "account_migrations", "accounts", on_delete: :cascade
  1128. add_foreign_key "account_moderation_notes", "accounts"
  1129. add_foreign_key "account_moderation_notes", "accounts", column: "target_account_id"
  1130. add_foreign_key "account_notes", "accounts", column: "target_account_id", on_delete: :cascade
  1131. add_foreign_key "account_notes", "accounts", on_delete: :cascade
  1132. add_foreign_key "account_pins", "accounts", column: "target_account_id", on_delete: :cascade
  1133. add_foreign_key "account_pins", "accounts", on_delete: :cascade
  1134. add_foreign_key "account_relationship_severance_events", "accounts", on_delete: :cascade
  1135. add_foreign_key "account_relationship_severance_events", "relationship_severance_events", on_delete: :cascade
  1136. add_foreign_key "account_stats", "accounts", on_delete: :cascade
  1137. add_foreign_key "account_statuses_cleanup_policies", "accounts", on_delete: :cascade
  1138. add_foreign_key "account_warnings", "accounts", column: "target_account_id", on_delete: :cascade
  1139. add_foreign_key "account_warnings", "accounts", on_delete: :nullify
  1140. add_foreign_key "account_warnings", "reports", on_delete: :cascade
  1141. add_foreign_key "accounts", "accounts", column: "moved_to_account_id", on_delete: :nullify
  1142. add_foreign_key "admin_action_logs", "accounts", on_delete: :cascade
  1143. add_foreign_key "announcement_mutes", "accounts", on_delete: :cascade
  1144. add_foreign_key "announcement_mutes", "announcements", on_delete: :cascade
  1145. add_foreign_key "announcement_reactions", "accounts", on_delete: :cascade
  1146. add_foreign_key "announcement_reactions", "announcements", on_delete: :cascade
  1147. add_foreign_key "announcement_reactions", "custom_emojis", on_delete: :cascade
  1148. add_foreign_key "appeals", "account_warnings", on_delete: :cascade
  1149. add_foreign_key "appeals", "accounts", column: "approved_by_account_id", on_delete: :nullify
  1150. add_foreign_key "appeals", "accounts", column: "rejected_by_account_id", on_delete: :nullify
  1151. add_foreign_key "appeals", "accounts", on_delete: :cascade
  1152. add_foreign_key "backups", "users", on_delete: :nullify
  1153. add_foreign_key "blocks", "accounts", column: "target_account_id", name: "fk_9571bfabc1", on_delete: :cascade
  1154. add_foreign_key "blocks", "accounts", name: "fk_4269e03e65", on_delete: :cascade
  1155. add_foreign_key "bookmarks", "accounts", on_delete: :cascade
  1156. add_foreign_key "bookmarks", "statuses", on_delete: :cascade
  1157. add_foreign_key "bulk_import_rows", "bulk_imports", on_delete: :cascade
  1158. add_foreign_key "bulk_imports", "accounts", on_delete: :cascade
  1159. add_foreign_key "canonical_email_blocks", "accounts", column: "reference_account_id", on_delete: :cascade
  1160. add_foreign_key "conversation_mutes", "accounts", name: "fk_225b4212bb", on_delete: :cascade
  1161. add_foreign_key "conversation_mutes", "conversations", on_delete: :cascade
  1162. add_foreign_key "custom_filter_keywords", "custom_filters", on_delete: :cascade
  1163. add_foreign_key "custom_filter_statuses", "custom_filters", on_delete: :cascade
  1164. add_foreign_key "custom_filter_statuses", "statuses", on_delete: :cascade
  1165. add_foreign_key "custom_filters", "accounts", on_delete: :cascade
  1166. add_foreign_key "email_domain_blocks", "email_domain_blocks", column: "parent_id", on_delete: :cascade
  1167. add_foreign_key "favourites", "accounts", name: "fk_5eb6c2b873", on_delete: :cascade
  1168. add_foreign_key "favourites", "statuses", name: "fk_b0e856845e", on_delete: :cascade
  1169. add_foreign_key "featured_tags", "accounts", on_delete: :cascade
  1170. add_foreign_key "featured_tags", "tags", on_delete: :cascade
  1171. add_foreign_key "follow_recommendation_mutes", "accounts", column: "target_account_id", on_delete: :cascade
  1172. add_foreign_key "follow_recommendation_mutes", "accounts", on_delete: :cascade
  1173. add_foreign_key "follow_recommendation_suppressions", "accounts", on_delete: :cascade
  1174. add_foreign_key "follow_requests", "accounts", column: "target_account_id", name: "fk_9291ec025d", on_delete: :cascade
  1175. add_foreign_key "follow_requests", "accounts", name: "fk_76d644b0e7", on_delete: :cascade
  1176. add_foreign_key "follows", "accounts", column: "target_account_id", name: "fk_745ca29eac", on_delete: :cascade
  1177. add_foreign_key "follows", "accounts", name: "fk_32ed1b5560", on_delete: :cascade
  1178. add_foreign_key "generated_annual_reports", "accounts"
  1179. add_foreign_key "identities", "users", name: "fk_bea040f377", on_delete: :cascade
  1180. add_foreign_key "imports", "accounts", name: "fk_6db1b6e408", on_delete: :cascade
  1181. add_foreign_key "invites", "users", on_delete: :cascade
  1182. add_foreign_key "list_accounts", "accounts", on_delete: :cascade
  1183. add_foreign_key "list_accounts", "follow_requests", on_delete: :cascade
  1184. add_foreign_key "list_accounts", "follows", on_delete: :cascade
  1185. add_foreign_key "list_accounts", "lists", on_delete: :cascade
  1186. add_foreign_key "lists", "accounts", on_delete: :cascade
  1187. add_foreign_key "login_activities", "users", on_delete: :cascade
  1188. add_foreign_key "markers", "users", on_delete: :cascade
  1189. add_foreign_key "media_attachments", "accounts", name: "fk_96dd81e81b", on_delete: :nullify
  1190. add_foreign_key "media_attachments", "scheduled_statuses", on_delete: :nullify
  1191. add_foreign_key "media_attachments", "statuses", on_delete: :nullify
  1192. add_foreign_key "mentions", "accounts", name: "fk_970d43f9d1", on_delete: :cascade
  1193. add_foreign_key "mentions", "statuses", on_delete: :cascade
  1194. add_foreign_key "mutes", "accounts", column: "target_account_id", name: "fk_eecff219ea", on_delete: :cascade
  1195. add_foreign_key "mutes", "accounts", name: "fk_b8d8daf315", on_delete: :cascade
  1196. add_foreign_key "notification_permissions", "accounts", column: "from_account_id", on_delete: :cascade
  1197. add_foreign_key "notification_permissions", "accounts", on_delete: :cascade
  1198. add_foreign_key "notification_policies", "accounts", on_delete: :cascade
  1199. add_foreign_key "notification_requests", "accounts", column: "from_account_id", on_delete: :cascade
  1200. add_foreign_key "notification_requests", "accounts", on_delete: :cascade
  1201. add_foreign_key "notification_requests", "statuses", column: "last_status_id", on_delete: :nullify
  1202. add_foreign_key "notifications", "accounts", column: "from_account_id", name: "fk_fbd6b0bf9e", on_delete: :cascade
  1203. add_foreign_key "notifications", "accounts", name: "fk_c141c8ee55", on_delete: :cascade
  1204. add_foreign_key "oauth_access_grants", "oauth_applications", column: "application_id", name: "fk_34d54b0a33", on_delete: :cascade
  1205. add_foreign_key "oauth_access_grants", "users", column: "resource_owner_id", name: "fk_63b044929b", on_delete: :cascade
  1206. add_foreign_key "oauth_access_tokens", "oauth_applications", column: "application_id", name: "fk_f5fc4c1ee3", on_delete: :cascade
  1207. add_foreign_key "oauth_access_tokens", "users", column: "resource_owner_id", name: "fk_e84df68546", on_delete: :cascade
  1208. add_foreign_key "oauth_applications", "users", column: "owner_id", name: "fk_b0988c7c0a", on_delete: :cascade
  1209. add_foreign_key "poll_votes", "accounts", on_delete: :cascade
  1210. add_foreign_key "poll_votes", "polls", on_delete: :cascade
  1211. add_foreign_key "polls", "accounts", on_delete: :cascade
  1212. add_foreign_key "polls", "statuses", on_delete: :cascade
  1213. add_foreign_key "preview_card_trends", "preview_cards", on_delete: :cascade
  1214. add_foreign_key "preview_cards", "accounts", column: "author_account_id", on_delete: :nullify
  1215. add_foreign_key "report_notes", "accounts", on_delete: :cascade
  1216. add_foreign_key "report_notes", "reports", on_delete: :cascade
  1217. add_foreign_key "reports", "accounts", column: "action_taken_by_account_id", name: "fk_bca45b75fd", on_delete: :nullify
  1218. add_foreign_key "reports", "accounts", column: "assigned_account_id", on_delete: :nullify
  1219. add_foreign_key "reports", "accounts", column: "target_account_id", name: "fk_eb37af34f0", on_delete: :cascade
  1220. add_foreign_key "reports", "accounts", name: "fk_4b81f7522c", on_delete: :cascade
  1221. add_foreign_key "reports", "oauth_applications", column: "application_id", on_delete: :nullify
  1222. add_foreign_key "scheduled_statuses", "accounts", on_delete: :cascade
  1223. add_foreign_key "session_activations", "oauth_access_tokens", column: "access_token_id", name: "fk_957e5bda89", on_delete: :cascade
  1224. add_foreign_key "session_activations", "users", name: "fk_e5fda67334", on_delete: :cascade
  1225. add_foreign_key "severed_relationships", "accounts", column: "local_account_id", on_delete: :cascade
  1226. add_foreign_key "severed_relationships", "accounts", column: "remote_account_id", on_delete: :cascade
  1227. add_foreign_key "severed_relationships", "relationship_severance_events", on_delete: :cascade
  1228. add_foreign_key "status_edits", "accounts", on_delete: :nullify
  1229. add_foreign_key "status_edits", "statuses", on_delete: :cascade
  1230. add_foreign_key "status_pins", "accounts", name: "fk_d4cb435b62", on_delete: :cascade
  1231. add_foreign_key "status_pins", "statuses", on_delete: :cascade
  1232. add_foreign_key "status_stats", "statuses", on_delete: :cascade
  1233. add_foreign_key "status_trends", "accounts", on_delete: :cascade
  1234. add_foreign_key "status_trends", "statuses", on_delete: :cascade
  1235. add_foreign_key "statuses", "accounts", column: "in_reply_to_account_id", name: "fk_c7fa917661", on_delete: :nullify
  1236. add_foreign_key "statuses", "accounts", name: "fk_9bda1543f7", on_delete: :cascade
  1237. add_foreign_key "statuses", "statuses", column: "in_reply_to_id", on_delete: :nullify
  1238. add_foreign_key "statuses", "statuses", column: "reblog_of_id", on_delete: :cascade
  1239. add_foreign_key "statuses_tags", "statuses", on_delete: :cascade
  1240. add_foreign_key "statuses_tags", "tags", name: "fk_3081861e21", on_delete: :cascade
  1241. add_foreign_key "tag_follows", "accounts", on_delete: :cascade
  1242. add_foreign_key "tag_follows", "tags", on_delete: :cascade
  1243. add_foreign_key "tombstones", "accounts", on_delete: :cascade
  1244. add_foreign_key "user_invite_requests", "users", on_delete: :cascade
  1245. add_foreign_key "users", "accounts", name: "fk_50500f500d", on_delete: :cascade
  1246. add_foreign_key "users", "invites", on_delete: :nullify
  1247. add_foreign_key "users", "oauth_applications", column: "created_by_application_id", on_delete: :nullify
  1248. add_foreign_key "users", "user_roles", column: "role_id", on_delete: :nullify
  1249. add_foreign_key "web_push_subscriptions", "oauth_access_tokens", column: "access_token_id", on_delete: :cascade
  1250. add_foreign_key "web_push_subscriptions", "users", on_delete: :cascade
  1251. add_foreign_key "web_settings", "users", name: "fk_11910667b2", on_delete: :cascade
  1252. add_foreign_key "webauthn_credentials", "users"
  1253. create_view "instances", materialized: true, sql_definition: <<-SQL
  1254. WITH domain_counts(domain, accounts_count) AS (
  1255. SELECT accounts.domain,
  1256. count(*) AS accounts_count
  1257. FROM accounts
  1258. WHERE (accounts.domain IS NOT NULL)
  1259. GROUP BY accounts.domain
  1260. )
  1261. SELECT domain_counts.domain,
  1262. domain_counts.accounts_count
  1263. FROM domain_counts
  1264. UNION
  1265. SELECT domain_blocks.domain,
  1266. COALESCE(domain_counts.accounts_count, (0)::bigint) AS accounts_count
  1267. FROM (domain_blocks
  1268. LEFT JOIN domain_counts ON (((domain_counts.domain)::text = (domain_blocks.domain)::text)))
  1269. UNION
  1270. SELECT domain_allows.domain,
  1271. COALESCE(domain_counts.accounts_count, (0)::bigint) AS accounts_count
  1272. FROM (domain_allows
  1273. LEFT JOIN domain_counts ON (((domain_counts.domain)::text = (domain_allows.domain)::text)));
  1274. SQL
  1275. add_index "instances", "reverse(('.'::text || (domain)::text)), domain", name: "index_instances_on_reverse_domain"
  1276. add_index "instances", ["domain"], name: "index_instances_on_domain", unique: true
  1277. create_view "user_ips", sql_definition: <<-SQL
  1278. SELECT user_id,
  1279. ip,
  1280. max(used_at) AS used_at
  1281. FROM ( SELECT users.id AS user_id,
  1282. users.sign_up_ip AS ip,
  1283. users.created_at AS used_at
  1284. FROM users
  1285. WHERE (users.sign_up_ip IS NOT NULL)
  1286. UNION ALL
  1287. SELECT session_activations.user_id,
  1288. session_activations.ip,
  1289. session_activations.updated_at
  1290. FROM session_activations
  1291. UNION ALL
  1292. SELECT login_activities.user_id,
  1293. login_activities.ip,
  1294. login_activities.created_at
  1295. FROM login_activities
  1296. WHERE (login_activities.success = true)) t0
  1297. GROUP BY user_id, ip;
  1298. SQL
  1299. create_view "account_summaries", materialized: true, sql_definition: <<-SQL
  1300. SELECT accounts.id AS account_id,
  1301. mode() WITHIN GROUP (ORDER BY t0.language) AS language,
  1302. mode() WITHIN GROUP (ORDER BY t0.sensitive) AS sensitive
  1303. FROM (accounts
  1304. CROSS JOIN LATERAL ( SELECT statuses.account_id,
  1305. statuses.language,
  1306. statuses.sensitive
  1307. FROM statuses
  1308. WHERE ((statuses.account_id = accounts.id) AND (statuses.deleted_at IS NULL) AND (statuses.reblog_of_id IS NULL))
  1309. ORDER BY statuses.id DESC
  1310. LIMIT 20) t0)
  1311. 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))
  1312. GROUP BY accounts.id;
  1313. SQL
  1314. add_index "account_summaries", ["account_id", "language", "sensitive"], name: "idx_on_account_id_language_sensitive_250461e1eb"
  1315. add_index "account_summaries", ["account_id"], name: "index_account_summaries_on_account_id", unique: true
  1316. create_view "global_follow_recommendations", materialized: true, sql_definition: <<-SQL
  1317. SELECT account_id,
  1318. sum(rank) AS rank,
  1319. array_agg(reason) AS reason
  1320. FROM ( SELECT account_summaries.account_id,
  1321. ((count(follows.id))::numeric / (1.0 + (count(follows.id))::numeric)) AS rank,
  1322. 'most_followed'::text AS reason
  1323. FROM ((follows
  1324. JOIN account_summaries ON ((account_summaries.account_id = follows.target_account_id)))
  1325. JOIN users ON ((users.account_id = follows.account_id)))
  1326. WHERE ((users.current_sign_in_at >= (now() - 'P30D'::interval)) AND (account_summaries.sensitive = false) AND (NOT (EXISTS ( SELECT 1
  1327. FROM follow_recommendation_suppressions
  1328. WHERE (follow_recommendation_suppressions.account_id = follows.target_account_id)))))
  1329. GROUP BY account_summaries.account_id
  1330. HAVING (count(follows.id) >= 5)
  1331. UNION ALL
  1332. SELECT account_summaries.account_id,
  1333. (sum((status_stats.reblogs_count + status_stats.favourites_count)) / (1.0 + sum((status_stats.reblogs_count + status_stats.favourites_count)))) AS rank,
  1334. 'most_interactions'::text AS reason
  1335. FROM ((status_stats
  1336. JOIN statuses ON ((statuses.id = status_stats.status_id)))
  1337. JOIN account_summaries ON ((account_summaries.account_id = statuses.account_id)))
  1338. 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
  1339. FROM follow_recommendation_suppressions
  1340. WHERE (follow_recommendation_suppressions.account_id = statuses.account_id)))))
  1341. GROUP BY account_summaries.account_id
  1342. HAVING (sum((status_stats.reblogs_count + status_stats.favourites_count)) >= (5)::numeric)) t0
  1343. GROUP BY account_id
  1344. ORDER BY (sum(rank)) DESC;
  1345. SQL
  1346. add_index "global_follow_recommendations", ["account_id"], name: "index_global_follow_recommendations_on_account_id", unique: true
  1347. end