schema.rb 61 KB

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