schema.rb 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  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: 20170905044538) do
  13. # These are extensions that must be enabled in order to support this database
  14. enable_extension "plpgsql"
  15. create_table "account_domain_blocks", id: :serial, force: :cascade do |t|
  16. t.integer "account_id"
  17. t.string "domain"
  18. t.datetime "created_at", null: false
  19. t.datetime "updated_at", null: false
  20. t.index ["account_id", "domain"], name: "index_account_domain_blocks_on_account_id_and_domain", unique: true
  21. end
  22. create_table "accounts", id: :serial, force: :cascade do |t|
  23. t.string "username", default: "", null: false
  24. t.string "domain"
  25. t.string "secret", default: "", null: false
  26. t.text "private_key"
  27. t.text "public_key", default: "", null: false
  28. t.string "remote_url", default: "", null: false
  29. t.string "salmon_url", default: "", null: false
  30. t.string "hub_url", default: "", null: false
  31. t.datetime "created_at", null: false
  32. t.datetime "updated_at", null: false
  33. t.text "note", default: "", null: false
  34. t.string "display_name", default: "", null: false
  35. t.string "uri", default: "", null: false
  36. t.string "url"
  37. t.string "avatar_file_name"
  38. t.string "avatar_content_type"
  39. t.integer "avatar_file_size"
  40. t.datetime "avatar_updated_at"
  41. t.string "header_file_name"
  42. t.string "header_content_type"
  43. t.integer "header_file_size"
  44. t.datetime "header_updated_at"
  45. t.string "avatar_remote_url"
  46. t.datetime "subscription_expires_at"
  47. t.boolean "silenced", default: false, null: false
  48. t.boolean "suspended", default: false, null: false
  49. t.boolean "locked", default: false, null: false
  50. t.string "header_remote_url", default: "", null: false
  51. t.integer "statuses_count", default: 0, null: false
  52. t.integer "followers_count", default: 0, null: false
  53. t.integer "following_count", default: 0, null: false
  54. t.datetime "last_webfingered_at"
  55. t.string "inbox_url", default: "", null: false
  56. t.string "outbox_url", default: "", null: false
  57. t.string "shared_inbox_url", default: "", null: false
  58. t.string "followers_url", default: "", null: false
  59. t.integer "protocol", default: 0, null: false
  60. 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
  61. t.index "lower((username)::text), lower((domain)::text)", name: "index_accounts_on_username_and_domain_lower"
  62. t.index ["uri"], name: "index_accounts_on_uri"
  63. t.index ["url"], name: "index_accounts_on_url"
  64. t.index ["username", "domain"], name: "index_accounts_on_username_and_domain", unique: true
  65. end
  66. create_table "blocks", id: :serial, force: :cascade do |t|
  67. t.integer "account_id", null: false
  68. t.integer "target_account_id", null: false
  69. t.datetime "created_at", null: false
  70. t.datetime "updated_at", null: false
  71. t.index ["account_id", "target_account_id"], name: "index_blocks_on_account_id_and_target_account_id", unique: true
  72. end
  73. create_table "conversation_mutes", id: :serial, force: :cascade do |t|
  74. t.integer "account_id", null: false
  75. t.bigint "conversation_id", null: false
  76. t.index ["account_id", "conversation_id"], name: "index_conversation_mutes_on_account_id_and_conversation_id", unique: true
  77. end
  78. create_table "conversations", force: :cascade do |t|
  79. t.string "uri"
  80. t.datetime "created_at", null: false
  81. t.datetime "updated_at", null: false
  82. t.index ["uri"], name: "index_conversations_on_uri", unique: true
  83. end
  84. create_table "domain_blocks", id: :serial, force: :cascade do |t|
  85. t.string "domain", default: "", null: false
  86. t.datetime "created_at", null: false
  87. t.datetime "updated_at", null: false
  88. t.integer "severity", default: 0
  89. t.boolean "reject_media", default: false, null: false
  90. t.index ["domain"], name: "index_domain_blocks_on_domain", unique: true
  91. end
  92. create_table "favourites", id: :serial, force: :cascade do |t|
  93. t.integer "account_id", null: false
  94. t.integer "status_id", null: false
  95. t.datetime "created_at", null: false
  96. t.datetime "updated_at", null: false
  97. t.index ["account_id", "id"], name: "index_favourites_on_account_id_and_id"
  98. t.index ["account_id", "status_id"], name: "index_favourites_on_account_id_and_status_id", unique: true
  99. t.index ["status_id"], name: "index_favourites_on_status_id"
  100. end
  101. create_table "follow_requests", id: :serial, force: :cascade do |t|
  102. t.integer "account_id", null: false
  103. t.integer "target_account_id", null: false
  104. t.datetime "created_at", null: false
  105. t.datetime "updated_at", null: false
  106. t.index ["account_id", "target_account_id"], name: "index_follow_requests_on_account_id_and_target_account_id", unique: true
  107. end
  108. create_table "follows", id: :serial, force: :cascade do |t|
  109. t.integer "account_id", null: false
  110. t.integer "target_account_id", null: false
  111. t.datetime "created_at", null: false
  112. t.datetime "updated_at", null: false
  113. t.index ["account_id", "target_account_id"], name: "index_follows_on_account_id_and_target_account_id", unique: true
  114. end
  115. create_table "imports", id: :serial, force: :cascade do |t|
  116. t.integer "account_id", null: false
  117. t.integer "type", null: false
  118. t.boolean "approved", default: false, null: false
  119. t.datetime "created_at", null: false
  120. t.datetime "updated_at", null: false
  121. t.string "data_file_name"
  122. t.string "data_content_type"
  123. t.integer "data_file_size"
  124. t.datetime "data_updated_at"
  125. end
  126. create_table "media_attachments", id: :serial, force: :cascade do |t|
  127. t.bigint "status_id"
  128. t.string "file_file_name"
  129. t.string "file_content_type"
  130. t.integer "file_file_size"
  131. t.datetime "file_updated_at"
  132. t.string "remote_url", default: "", null: false
  133. t.integer "account_id"
  134. t.datetime "created_at", null: false
  135. t.datetime "updated_at", null: false
  136. t.string "shortcode"
  137. t.integer "type", default: 0, null: false
  138. t.json "file_meta"
  139. t.index ["account_id"], name: "index_media_attachments_on_account_id"
  140. t.index ["shortcode"], name: "index_media_attachments_on_shortcode", unique: true
  141. t.index ["status_id"], name: "index_media_attachments_on_status_id"
  142. end
  143. create_table "mentions", id: :serial, force: :cascade do |t|
  144. t.integer "account_id"
  145. t.bigint "status_id"
  146. t.datetime "created_at", null: false
  147. t.datetime "updated_at", null: false
  148. t.index ["account_id", "status_id"], name: "index_mentions_on_account_id_and_status_id", unique: true
  149. t.index ["status_id"], name: "index_mentions_on_status_id"
  150. end
  151. create_table "mutes", id: :serial, force: :cascade do |t|
  152. t.integer "account_id", null: false
  153. t.integer "target_account_id", null: false
  154. t.datetime "created_at", null: false
  155. t.datetime "updated_at", null: false
  156. t.index ["account_id", "target_account_id"], name: "index_mutes_on_account_id_and_target_account_id", unique: true
  157. end
  158. create_table "notifications", id: :serial, force: :cascade do |t|
  159. t.integer "account_id"
  160. t.bigint "activity_id"
  161. t.string "activity_type"
  162. t.datetime "created_at", null: false
  163. t.datetime "updated_at", null: false
  164. t.integer "from_account_id"
  165. t.index ["account_id", "activity_id", "activity_type"], name: "account_activity", unique: true
  166. t.index ["activity_id", "activity_type"], name: "index_notifications_on_activity_id_and_activity_type"
  167. t.index ["id", "account_id", "activity_type"], name: "index_notifications_on_id_and_account_id_and_activity_type", order: { id: :desc }
  168. end
  169. create_table "oauth_access_grants", id: :serial, force: :cascade do |t|
  170. t.integer "resource_owner_id", null: false
  171. t.integer "application_id", null: false
  172. t.string "token", null: false
  173. t.integer "expires_in", null: false
  174. t.text "redirect_uri", null: false
  175. t.datetime "created_at", null: false
  176. t.datetime "revoked_at"
  177. t.string "scopes"
  178. t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true
  179. end
  180. create_table "oauth_access_tokens", id: :serial, force: :cascade do |t|
  181. t.integer "resource_owner_id"
  182. t.integer "application_id"
  183. t.string "token", null: false
  184. t.string "refresh_token"
  185. t.integer "expires_in"
  186. t.datetime "revoked_at"
  187. t.datetime "created_at", null: false
  188. t.string "scopes"
  189. t.index ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true
  190. t.index ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id"
  191. t.index ["token"], name: "index_oauth_access_tokens_on_token", unique: true
  192. end
  193. create_table "oauth_applications", id: :serial, force: :cascade do |t|
  194. t.string "name", null: false
  195. t.string "uid", null: false
  196. t.string "secret", null: false
  197. t.text "redirect_uri", null: false
  198. t.string "scopes", default: "", null: false
  199. t.datetime "created_at"
  200. t.datetime "updated_at"
  201. t.boolean "superapp", default: false, null: false
  202. t.string "website"
  203. t.integer "owner_id"
  204. t.string "owner_type"
  205. t.index ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type"
  206. t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true
  207. end
  208. create_table "preview_cards", force: :cascade do |t|
  209. t.string "url", default: "", null: false
  210. t.string "title", default: "", null: false
  211. t.string "description", default: "", null: false
  212. t.string "image_file_name"
  213. t.string "image_content_type"
  214. t.integer "image_file_size"
  215. t.datetime "image_updated_at"
  216. t.integer "type", default: 0, null: false
  217. t.text "html", default: "", null: false
  218. t.string "author_name", default: "", null: false
  219. t.string "author_url", default: "", null: false
  220. t.string "provider_name", default: "", null: false
  221. t.string "provider_url", default: "", null: false
  222. t.integer "width", default: 0, null: false
  223. t.integer "height", default: 0, null: false
  224. t.datetime "created_at", null: false
  225. t.datetime "updated_at", null: false
  226. t.index ["url"], name: "index_preview_cards_on_url", unique: true
  227. end
  228. create_table "preview_cards_statuses", id: false, force: :cascade do |t|
  229. t.bigint "preview_card_id", null: false
  230. t.bigint "status_id", null: false
  231. t.index ["status_id", "preview_card_id"], name: "index_preview_cards_statuses_on_status_id_and_preview_card_id"
  232. end
  233. create_table "reports", id: :serial, force: :cascade do |t|
  234. t.integer "account_id", null: false
  235. t.integer "target_account_id", null: false
  236. t.bigint "status_ids", default: [], null: false, array: true
  237. t.text "comment", default: "", null: false
  238. t.boolean "action_taken", default: false, null: false
  239. t.datetime "created_at", null: false
  240. t.datetime "updated_at", null: false
  241. t.integer "action_taken_by_account_id"
  242. t.index ["account_id"], name: "index_reports_on_account_id"
  243. t.index ["target_account_id"], name: "index_reports_on_target_account_id"
  244. end
  245. create_table "session_activations", force: :cascade do |t|
  246. t.integer "user_id", null: false
  247. t.string "session_id", null: false
  248. t.datetime "created_at", null: false
  249. t.datetime "updated_at", null: false
  250. t.string "user_agent", default: "", null: false
  251. t.inet "ip"
  252. t.integer "access_token_id"
  253. t.integer "web_push_subscription_id"
  254. t.index ["session_id"], name: "index_session_activations_on_session_id", unique: true
  255. t.index ["user_id"], name: "index_session_activations_on_user_id"
  256. end
  257. create_table "settings", id: :serial, force: :cascade do |t|
  258. t.string "var", null: false
  259. t.text "value"
  260. t.string "thing_type"
  261. t.integer "thing_id"
  262. t.datetime "created_at"
  263. t.datetime "updated_at"
  264. t.index ["thing_type", "thing_id", "var"], name: "index_settings_on_thing_type_and_thing_id_and_var", unique: true
  265. end
  266. create_table "status_pins", force: :cascade do |t|
  267. t.bigint "account_id", null: false
  268. t.bigint "status_id", null: false
  269. t.datetime "created_at", default: -> { "now()" }, null: false
  270. t.datetime "updated_at", default: -> { "now()" }, null: false
  271. t.index ["account_id", "status_id"], name: "index_status_pins_on_account_id_and_status_id", unique: true
  272. end
  273. create_table "statuses", force: :cascade do |t|
  274. t.string "uri"
  275. t.integer "account_id", null: false
  276. t.text "text", default: "", null: false
  277. t.datetime "created_at", null: false
  278. t.datetime "updated_at", null: false
  279. t.bigint "in_reply_to_id"
  280. t.bigint "reblog_of_id"
  281. t.string "url"
  282. t.boolean "sensitive", default: false, null: false
  283. t.integer "visibility", default: 0, null: false
  284. t.integer "in_reply_to_account_id"
  285. t.integer "application_id"
  286. t.text "spoiler_text", default: "", null: false
  287. t.boolean "reply", default: false, null: false
  288. t.integer "favourites_count", default: 0, null: false
  289. t.integer "reblogs_count", default: 0, null: false
  290. t.string "language"
  291. t.bigint "conversation_id"
  292. t.index ["account_id", "id"], name: "index_statuses_on_account_id_id"
  293. t.index ["conversation_id"], name: "index_statuses_on_conversation_id"
  294. t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id"
  295. t.index ["reblog_of_id"], name: "index_statuses_on_reblog_of_id"
  296. t.index ["uri"], name: "index_statuses_on_uri", unique: true
  297. end
  298. create_table "statuses_tags", id: false, force: :cascade do |t|
  299. t.bigint "status_id", null: false
  300. t.integer "tag_id", null: false
  301. t.index ["status_id"], name: "index_statuses_tags_on_status_id"
  302. t.index ["tag_id", "status_id"], name: "index_statuses_tags_on_tag_id_and_status_id", unique: true
  303. end
  304. create_table "stream_entries", id: :serial, force: :cascade do |t|
  305. t.integer "account_id"
  306. t.bigint "activity_id"
  307. t.string "activity_type"
  308. t.datetime "created_at", null: false
  309. t.datetime "updated_at", null: false
  310. t.boolean "hidden", default: false, null: false
  311. t.index ["account_id"], name: "index_stream_entries_on_account_id"
  312. t.index ["activity_id", "activity_type"], name: "index_stream_entries_on_activity_id_and_activity_type"
  313. end
  314. create_table "subscriptions", id: :serial, force: :cascade do |t|
  315. t.string "callback_url", default: "", null: false
  316. t.string "secret"
  317. t.datetime "expires_at"
  318. t.boolean "confirmed", default: false, null: false
  319. t.integer "account_id", null: false
  320. t.datetime "created_at", null: false
  321. t.datetime "updated_at", null: false
  322. t.datetime "last_successful_delivery_at"
  323. t.string "domain"
  324. t.index ["account_id", "callback_url"], name: "index_subscriptions_on_account_id_and_callback_url", unique: true
  325. end
  326. create_table "tags", id: :serial, force: :cascade do |t|
  327. t.string "name", default: "", null: false
  328. t.datetime "created_at", null: false
  329. t.datetime "updated_at", null: false
  330. t.index "lower((name)::text) text_pattern_ops", name: "hashtag_search_index"
  331. t.index ["name"], name: "index_tags_on_name", unique: true
  332. end
  333. create_table "users", id: :serial, force: :cascade do |t|
  334. t.string "email", default: "", null: false
  335. t.integer "account_id", null: false
  336. t.datetime "created_at", null: false
  337. t.datetime "updated_at", null: false
  338. t.string "encrypted_password", default: "", null: false
  339. t.string "reset_password_token"
  340. t.datetime "reset_password_sent_at"
  341. t.datetime "remember_created_at"
  342. t.integer "sign_in_count", default: 0, null: false
  343. t.datetime "current_sign_in_at"
  344. t.datetime "last_sign_in_at"
  345. t.inet "current_sign_in_ip"
  346. t.inet "last_sign_in_ip"
  347. t.boolean "admin", default: false, null: false
  348. t.string "confirmation_token"
  349. t.datetime "confirmed_at"
  350. t.datetime "confirmation_sent_at"
  351. t.string "unconfirmed_email"
  352. t.string "locale"
  353. t.string "encrypted_otp_secret"
  354. t.string "encrypted_otp_secret_iv"
  355. t.string "encrypted_otp_secret_salt"
  356. t.integer "consumed_timestep"
  357. t.boolean "otp_required_for_login", default: false, null: false
  358. t.datetime "last_emailed_at"
  359. t.string "otp_backup_codes", array: true
  360. t.string "filtered_languages", default: [], null: false, array: true
  361. t.index ["account_id"], name: "index_users_on_account_id"
  362. t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
  363. t.index ["email"], name: "index_users_on_email", unique: true
  364. t.index ["filtered_languages"], name: "index_users_on_filtered_languages", using: :gin
  365. t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
  366. end
  367. create_table "web_push_subscriptions", force: :cascade do |t|
  368. t.string "endpoint", null: false
  369. t.string "key_p256dh", null: false
  370. t.string "key_auth", null: false
  371. t.json "data"
  372. t.datetime "created_at", null: false
  373. t.datetime "updated_at", null: false
  374. end
  375. create_table "web_settings", id: :serial, force: :cascade do |t|
  376. t.integer "user_id"
  377. t.json "data"
  378. t.datetime "created_at", null: false
  379. t.datetime "updated_at", null: false
  380. t.index ["user_id"], name: "index_web_settings_on_user_id", unique: true
  381. end
  382. add_foreign_key "account_domain_blocks", "accounts", on_delete: :cascade
  383. add_foreign_key "blocks", "accounts", column: "target_account_id", on_delete: :cascade
  384. add_foreign_key "blocks", "accounts", on_delete: :cascade
  385. add_foreign_key "conversation_mutes", "accounts", on_delete: :cascade
  386. add_foreign_key "conversation_mutes", "conversations", on_delete: :cascade
  387. add_foreign_key "favourites", "accounts", on_delete: :cascade
  388. add_foreign_key "favourites", "statuses", on_delete: :cascade
  389. add_foreign_key "follow_requests", "accounts", column: "target_account_id", on_delete: :cascade
  390. add_foreign_key "follow_requests", "accounts", on_delete: :cascade
  391. add_foreign_key "follows", "accounts", column: "target_account_id", on_delete: :cascade
  392. add_foreign_key "follows", "accounts", on_delete: :cascade
  393. add_foreign_key "imports", "accounts", on_delete: :cascade
  394. add_foreign_key "media_attachments", "accounts", on_delete: :nullify
  395. add_foreign_key "media_attachments", "statuses", on_delete: :nullify
  396. add_foreign_key "mentions", "accounts", on_delete: :cascade
  397. add_foreign_key "mentions", "statuses", on_delete: :cascade
  398. add_foreign_key "mutes", "accounts", column: "target_account_id", on_delete: :cascade
  399. add_foreign_key "mutes", "accounts", on_delete: :cascade
  400. add_foreign_key "notifications", "accounts", column: "from_account_id", on_delete: :cascade
  401. add_foreign_key "notifications", "accounts", on_delete: :cascade
  402. add_foreign_key "oauth_access_grants", "oauth_applications", column: "application_id", on_delete: :cascade
  403. add_foreign_key "oauth_access_grants", "users", column: "resource_owner_id", on_delete: :cascade
  404. add_foreign_key "oauth_access_tokens", "oauth_applications", column: "application_id", on_delete: :cascade
  405. add_foreign_key "oauth_access_tokens", "users", column: "resource_owner_id", on_delete: :cascade
  406. add_foreign_key "oauth_applications", "users", column: "owner_id", on_delete: :cascade
  407. add_foreign_key "reports", "accounts", column: "action_taken_by_account_id", on_delete: :nullify
  408. add_foreign_key "reports", "accounts", column: "target_account_id", on_delete: :cascade
  409. add_foreign_key "reports", "accounts", on_delete: :cascade
  410. add_foreign_key "session_activations", "oauth_access_tokens", column: "access_token_id", on_delete: :cascade
  411. add_foreign_key "session_activations", "users", on_delete: :cascade
  412. add_foreign_key "status_pins", "accounts", on_delete: :cascade
  413. add_foreign_key "status_pins", "statuses", on_delete: :cascade
  414. add_foreign_key "statuses", "accounts", column: "in_reply_to_account_id", on_delete: :nullify
  415. add_foreign_key "statuses", "accounts", on_delete: :cascade
  416. add_foreign_key "statuses", "statuses", column: "in_reply_to_id", on_delete: :nullify
  417. add_foreign_key "statuses", "statuses", column: "reblog_of_id", on_delete: :cascade
  418. add_foreign_key "statuses_tags", "statuses", on_delete: :cascade
  419. add_foreign_key "statuses_tags", "tags", on_delete: :cascade
  420. add_foreign_key "stream_entries", "accounts", on_delete: :cascade
  421. add_foreign_key "subscriptions", "accounts", on_delete: :cascade
  422. add_foreign_key "users", "accounts", on_delete: :cascade
  423. add_foreign_key "web_settings", "users", on_delete: :cascade
  424. end