schema.rb 48 KB

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