about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20170918125918_ids_to_bigints.rb232
-rw-r--r--db/schema.rb134
2 files changed, 179 insertions, 187 deletions
diff --git a/db/migrate/20170918125918_ids_to_bigints.rb b/db/migrate/20170918125918_ids_to_bigints.rb
index 7483dd77a..c6feed8f9 100644
--- a/db/migrate/20170918125918_ids_to_bigints.rb
+++ b/db/migrate/20170918125918_ids_to_bigints.rb
@@ -1,127 +1,119 @@
+require Rails.root.join('lib', 'mastodon', 'migration_helpers')
+
 class IdsToBigints < ActiveRecord::Migration[5.1]
+  include Mastodon::MigrationHelpers
+
+  disable_ddl_transaction!
+
+  INCLUDED_COLUMNS = [
+    [:account_domain_blocks, :account_id],
+    [:account_domain_blocks, :id],
+    [:accounts, :id],
+    [:blocks, :account_id],
+    [:blocks, :id],
+    [:blocks, :target_account_id],
+    [:conversation_mutes, :account_id],
+    [:conversation_mutes, :id],
+    [:domain_blocks, :id],
+    [:favourites, :account_id],
+    [:favourites, :id],
+    [:favourites, :status_id],
+    [:follow_requests, :account_id],
+    [:follow_requests, :id],
+    [:follow_requests, :target_account_id],
+    [:follows, :account_id],
+    [:follows, :id],
+    [:follows, :target_account_id],
+    [:imports, :account_id],
+    [:imports, :id],
+    [:media_attachments, :account_id],
+    [:media_attachments, :id],
+    [:mentions, :account_id],
+    [:mentions, :id],
+    [:mutes, :account_id],
+    [:mutes, :id],
+    [:mutes, :target_account_id],
+    [:notifications, :account_id],
+    [:notifications, :from_account_id],
+    [:notifications, :id],
+    [:oauth_access_grants, :application_id],
+    [:oauth_access_grants, :id],
+    [:oauth_access_grants, :resource_owner_id],
+    [:oauth_access_tokens, :application_id],
+    [:oauth_access_tokens, :id],
+    [:oauth_access_tokens, :resource_owner_id],
+    [:oauth_applications, :id],
+    [:oauth_applications, :owner_id],
+    [:reports, :account_id],
+    [:reports, :action_taken_by_account_id],
+    [:reports, :id],
+    [:reports, :target_account_id],
+    [:session_activations, :access_token_id],
+    [:session_activations, :user_id],
+    [:session_activations, :web_push_subscription_id],
+    [:settings, :id],
+    [:settings, :thing_id],
+    [:statuses, :account_id],
+    [:statuses, :application_id],
+    [:statuses, :in_reply_to_account_id],
+    [:stream_entries, :account_id],
+    [:stream_entries, :id],
+    [:subscriptions, :account_id],
+    [:subscriptions, :id],
+    [:tags, :id],
+    [:users, :account_id],
+    [:users, :id],
+    [:web_settings, :id],
+    [:web_settings, :user_id],
+  ]
+  INCLUDED_COLUMNS << [:deprecated_preview_cards, :id] if table_exists?(:deprecated_preview_cards)
+
+  def migrate_columns(to_type)
+    # Print out a warning that this will probably take a while.
+    say ''
+    say 'WARNING: This migration may take a *long* time for large instances'
+    say 'It will *not* lock tables for any significant time, but it may run'
+    say 'for a very long time. We will pause for 10 seconds to allow you to'
+    say 'interrupt this migration if you are not ready.'
+    say ''
+    say 'This migration has some sections that can be safely interrupted'
+    say 'and restarted later, and will tell you when those are occurring.'
+    say ''
+    say 'For more information, see https://github.com/tootsuite/mastodon/pull/5088'
+
+    10.downto(1) do |i|
+      say "Continuing in #{i} second#{i == 1 ? '' : 's'}...", true
+      sleep 1
+    end
+
+    tables = INCLUDED_COLUMNS.map(&:first).uniq
+    table_sizes = {}
+
+    # Sort tables by their size
+    tables.each do |table|
+      table_sizes[table] = estimate_rows_in_table(table)
+    end
+
+    ordered_columns = INCLUDED_COLUMNS.sort_by do |col_parts|
+      [-table_sizes[col_parts.first], col_parts.last]
+    end
+
+    ordered_columns.each do |column_parts|
+      table, column = column_parts
+
+      # Skip this if we're resuming and already did this one.
+      next if column_for(table, column).sql_type == to_type.to_s
+
+      change_column_type_concurrently table, column, to_type
+      cleanup_concurrent_column_type_change table, column
+    end
+  end
+
   def up
-    change_column :account_domain_blocks, :account_id, :bigint
-    change_column :account_domain_blocks, :id, :bigint
-    change_column :accounts, :id, :bigint
-    change_column :blocks, :account_id, :bigint
-    change_column :blocks, :id, :bigint
-    change_column :blocks, :target_account_id, :bigint
-    change_column :conversation_mutes, :account_id, :bigint
-    change_column :conversation_mutes, :id, :bigint
-    change_column :deprecated_preview_cards, :id, :bigint if table_exists?(:deprecated_preview_cards)
-    change_column :domain_blocks, :id, :bigint
-    change_column :favourites, :account_id, :bigint
-    change_column :favourites, :id, :bigint
-    change_column :favourites, :status_id, :bigint
-    change_column :follow_requests, :account_id, :bigint
-    change_column :follow_requests, :id, :bigint
-    change_column :follow_requests, :target_account_id, :bigint
-    change_column :follows, :account_id, :bigint
-    change_column :follows, :id, :bigint
-    change_column :follows, :target_account_id, :bigint
-    change_column :imports, :account_id, :bigint
-    change_column :imports, :id, :bigint
-    change_column :media_attachments, :account_id, :bigint
-    change_column :media_attachments, :id, :bigint
-    change_column :mentions, :account_id, :bigint
-    change_column :mentions, :id, :bigint
-    change_column :mutes, :account_id, :bigint
-    change_column :mutes, :id, :bigint
-    change_column :mutes, :target_account_id, :bigint
-    change_column :notifications, :account_id, :bigint
-    change_column :notifications, :from_account_id, :bigint
-    change_column :notifications, :id, :bigint
-    change_column :oauth_access_grants, :application_id, :bigint
-    change_column :oauth_access_grants, :id, :bigint
-    change_column :oauth_access_grants, :resource_owner_id, :bigint
-    change_column :oauth_access_tokens, :application_id, :bigint
-    change_column :oauth_access_tokens, :id, :bigint
-    change_column :oauth_access_tokens, :resource_owner_id, :bigint
-    change_column :oauth_applications, :id, :bigint
-    change_column :oauth_applications, :owner_id, :bigint
-    change_column :reports, :account_id, :bigint
-    change_column :reports, :action_taken_by_account_id, :bigint
-    change_column :reports, :id, :bigint
-    change_column :reports, :target_account_id, :bigint
-    change_column :session_activations, :access_token_id, :bigint
-    change_column :session_activations, :user_id, :bigint
-    change_column :session_activations, :web_push_subscription_id, :bigint
-    change_column :settings, :id, :bigint
-    change_column :settings, :thing_id, :bigint
-    change_column :statuses, :account_id, :bigint
-    change_column :statuses, :application_id, :bigint
-    change_column :statuses, :in_reply_to_account_id, :bigint
-    change_column :stream_entries, :account_id, :bigint
-    change_column :stream_entries, :id, :bigint
-    change_column :subscriptions, :account_id, :bigint
-    change_column :subscriptions, :id, :bigint
-    change_column :tags, :id, :bigint
-    change_column :users, :account_id, :bigint
-    change_column :users, :id, :bigint
-    change_column :web_settings, :id, :bigint
-    change_column :web_settings, :user_id, :bigint
+    migrate_columns(:bigint)
   end
 
   def down
-    change_column :account_domain_blocks, :account_id, :integer
-    change_column :account_domain_blocks, :id, :integer
-    change_column :accounts, :id, :integer
-    change_column :blocks, :account_id, :integer
-    change_column :blocks, :id, :integer
-    change_column :blocks, :target_account_id, :integer
-    change_column :conversation_mutes, :account_id, :integer
-    change_column :conversation_mutes, :id, :integer
-    change_column :deprecated_preview_cards, :id, :integer if table_exists?(:deprecated_preview_cards)
-    change_column :domain_blocks, :id, :integer
-    change_column :favourites, :account_id, :integer
-    change_column :favourites, :id, :integer
-    change_column :favourites, :status_id, :integer
-    change_column :follow_requests, :account_id, :integer
-    change_column :follow_requests, :id, :integer
-    change_column :follow_requests, :target_account_id, :integer
-    change_column :follows, :account_id, :integer
-    change_column :follows, :id, :integer
-    change_column :follows, :target_account_id, :integer
-    change_column :imports, :account_id, :integer
-    change_column :imports, :id, :integer
-    change_column :media_attachments, :account_id, :integer
-    change_column :media_attachments, :id, :integer
-    change_column :mentions, :account_id, :integer
-    change_column :mentions, :id, :integer
-    change_column :mutes, :account_id, :integer
-    change_column :mutes, :id, :integer
-    change_column :mutes, :target_account_id, :integer
-    change_column :notifications, :account_id, :integer
-    change_column :notifications, :from_account_id, :integer
-    change_column :notifications, :id, :integer
-    change_column :oauth_access_grants, :application_id, :integer
-    change_column :oauth_access_grants, :id, :integer
-    change_column :oauth_access_grants, :resource_owner_id, :integer
-    change_column :oauth_access_tokens, :application_id, :integer
-    change_column :oauth_access_tokens, :id, :integer
-    change_column :oauth_access_tokens, :resource_owner_id, :integer
-    change_column :oauth_applications, :id, :integer
-    change_column :oauth_applications, :owner_id, :integer
-    change_column :reports, :account_id, :integer
-    change_column :reports, :action_taken_by_account_id, :integer
-    change_column :reports, :id, :integer
-    change_column :reports, :target_account_id, :integer
-    change_column :session_activations, :access_token_id, :integer
-    change_column :session_activations, :user_id, :integer
-    change_column :session_activations, :web_push_subscription_id, :integer
-    change_column :settings, :id, :integer
-    change_column :settings, :thing_id, :integer
-    change_column :statuses, :account_id, :integer
-    change_column :statuses, :application_id, :integer
-    change_column :statuses, :in_reply_to_account_id, :integer
-    change_column :stream_entries, :account_id, :integer
-    change_column :stream_entries, :id, :integer
-    change_column :subscriptions, :account_id, :integer
-    change_column :subscriptions, :id, :integer
-    change_column :tags, :id, :integer
-    change_column :users, :account_id, :integer
-    change_column :users, :id, :integer
-    change_column :web_settings, :id, :integer
-    change_column :web_settings, :user_id, :integer
+    migrate_columns(:integer)
   end
 end
diff --git a/db/schema.rb b/db/schema.rb
index 90f8a5683..2cb105553 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -16,10 +16,10 @@ ActiveRecord::Schema.define(version: 20170927215609) do
   enable_extension "plpgsql"
 
   create_table "account_domain_blocks", force: :cascade do |t|
-    t.bigint "account_id"
     t.string "domain"
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
+    t.bigint "account_id"
     t.index ["account_id", "domain"], name: "index_account_domain_blocks_on_account_id_and_domain", unique: true
   end
 
@@ -69,16 +69,16 @@ ActiveRecord::Schema.define(version: 20170927215609) do
   end
 
   create_table "blocks", force: :cascade do |t|
-    t.bigint "account_id", null: false
-    t.bigint "target_account_id", null: false
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
+    t.bigint "account_id", null: false
+    t.bigint "target_account_id", null: false
     t.index ["account_id", "target_account_id"], name: "index_blocks_on_account_id_and_target_account_id", unique: true
   end
 
   create_table "conversation_mutes", force: :cascade do |t|
-    t.bigint "account_id", null: false
     t.bigint "conversation_id", null: false
+    t.bigint "account_id", null: false
     t.index ["account_id", "conversation_id"], name: "index_conversation_mutes_on_account_id_and_conversation_id", unique: true
   end
 
@@ -111,33 +111,32 @@ ActiveRecord::Schema.define(version: 20170927215609) do
   end
 
   create_table "favourites", force: :cascade do |t|
-    t.bigint "account_id", null: false
-    t.bigint "status_id", null: false
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
+    t.bigint "account_id", null: false
+    t.bigint "status_id", null: false
     t.index ["account_id", "id"], name: "index_favourites_on_account_id_and_id"
     t.index ["account_id", "status_id"], name: "index_favourites_on_account_id_and_status_id", unique: true
     t.index ["status_id"], name: "index_favourites_on_status_id"
   end
 
   create_table "follow_requests", force: :cascade do |t|
-    t.bigint "account_id", null: false
-    t.bigint "target_account_id", null: false
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
+    t.bigint "account_id", null: false
+    t.bigint "target_account_id", null: false
     t.index ["account_id", "target_account_id"], name: "index_follow_requests_on_account_id_and_target_account_id", unique: true
   end
 
   create_table "follows", force: :cascade do |t|
-    t.bigint "account_id", null: false
-    t.bigint "target_account_id", null: false
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
+    t.bigint "account_id", null: false
+    t.bigint "target_account_id", null: false
     t.index ["account_id", "target_account_id"], name: "index_follows_on_account_id_and_target_account_id", unique: true
   end
 
   create_table "imports", force: :cascade do |t|
-    t.bigint "account_id", null: false
     t.integer "type", null: false
     t.boolean "approved", default: false, null: false
     t.datetime "created_at", null: false
@@ -146,6 +145,7 @@ ActiveRecord::Schema.define(version: 20170927215609) do
     t.string "data_content_type"
     t.integer "data_file_size"
     t.datetime "data_updated_at"
+    t.bigint "account_id", null: false
   end
 
   create_table "media_attachments", force: :cascade do |t|
@@ -155,12 +155,12 @@ ActiveRecord::Schema.define(version: 20170927215609) do
     t.integer "file_file_size"
     t.datetime "file_updated_at"
     t.string "remote_url", default: "", null: false
-    t.bigint "account_id"
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
     t.string "shortcode"
     t.integer "type", default: 0, null: false
     t.json "file_meta"
+    t.bigint "account_id"
     t.text "description"
     t.index ["account_id"], name: "index_media_attachments_on_account_id"
     t.index ["shortcode"], name: "index_media_attachments_on_shortcode", unique: true
@@ -168,28 +168,28 @@ ActiveRecord::Schema.define(version: 20170927215609) do
   end
 
   create_table "mentions", force: :cascade do |t|
-    t.bigint "account_id"
     t.bigint "status_id"
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
+    t.bigint "account_id"
     t.index ["account_id", "status_id"], name: "index_mentions_on_account_id_and_status_id", unique: true
     t.index ["status_id"], name: "index_mentions_on_status_id"
   end
 
   create_table "mutes", force: :cascade do |t|
-    t.bigint "account_id", null: false
-    t.bigint "target_account_id", null: false
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
+    t.bigint "account_id", null: false
+    t.bigint "target_account_id", null: false
     t.index ["account_id", "target_account_id"], name: "index_mutes_on_account_id_and_target_account_id", unique: true
   end
 
   create_table "notifications", force: :cascade do |t|
-    t.bigint "account_id"
     t.bigint "activity_id"
     t.string "activity_type"
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
+    t.bigint "account_id"
     t.bigint "from_account_id"
     t.index ["account_id", "activity_id", "activity_type"], name: "account_activity", unique: true
     t.index ["activity_id", "activity_type"], name: "index_notifications_on_activity_id_and_activity_type"
@@ -197,26 +197,26 @@ ActiveRecord::Schema.define(version: 20170927215609) do
   end
 
   create_table "oauth_access_grants", force: :cascade do |t|
-    t.bigint "resource_owner_id", null: false
-    t.bigint "application_id", null: false
     t.string "token", null: false
     t.integer "expires_in", null: false
     t.text "redirect_uri", null: false
     t.datetime "created_at", null: false
     t.datetime "revoked_at"
     t.string "scopes"
+    t.bigint "application_id", null: false
+    t.bigint "resource_owner_id", null: false
     t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true
   end
 
   create_table "oauth_access_tokens", force: :cascade do |t|
-    t.bigint "resource_owner_id"
-    t.bigint "application_id"
     t.string "token", null: false
     t.string "refresh_token"
     t.integer "expires_in"
     t.datetime "revoked_at"
     t.datetime "created_at", null: false
     t.string "scopes"
+    t.bigint "application_id"
+    t.bigint "resource_owner_id"
     t.index ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true
     t.index ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id"
     t.index ["token"], name: "index_oauth_access_tokens_on_token", unique: true
@@ -232,8 +232,8 @@ ActiveRecord::Schema.define(version: 20170927215609) do
     t.datetime "updated_at"
     t.boolean "superapp", default: false, null: false
     t.string "website"
-    t.bigint "owner_id"
     t.string "owner_type"
+    t.bigint "owner_id"
     t.index ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type"
     t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true
   end
@@ -266,26 +266,26 @@ ActiveRecord::Schema.define(version: 20170927215609) do
   end
 
   create_table "reports", force: :cascade do |t|
-    t.bigint "account_id", null: false
-    t.bigint "target_account_id", null: false
     t.bigint "status_ids", default: [], null: false, array: true
     t.text "comment", default: "", null: false
     t.boolean "action_taken", default: false, null: false
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
+    t.bigint "account_id", null: false
     t.bigint "action_taken_by_account_id"
+    t.bigint "target_account_id", null: false
     t.index ["account_id"], name: "index_reports_on_account_id"
     t.index ["target_account_id"], name: "index_reports_on_target_account_id"
   end
 
   create_table "session_activations", force: :cascade do |t|
-    t.bigint "user_id", null: false
     t.string "session_id", null: false
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
     t.string "user_agent", default: "", null: false
     t.inet "ip"
     t.bigint "access_token_id"
+    t.bigint "user_id", null: false
     t.bigint "web_push_subscription_id"
     t.index ["session_id"], name: "index_session_activations_on_session_id", unique: true
     t.index ["user_id"], name: "index_session_activations_on_user_id"
@@ -295,9 +295,9 @@ ActiveRecord::Schema.define(version: 20170927215609) do
     t.string "var", null: false
     t.text "value"
     t.string "thing_type"
-    t.bigint "thing_id"
     t.datetime "created_at"
     t.datetime "updated_at"
+    t.bigint "thing_id"
     t.index ["thing_type", "thing_id", "var"], name: "index_settings_on_thing_type_and_thing_id_and_var", unique: true
   end
 
@@ -323,7 +323,6 @@ ActiveRecord::Schema.define(version: 20170927215609) do
 
   create_table "statuses", force: :cascade do |t|
     t.string "uri"
-    t.bigint "account_id", null: false
     t.text "text", default: "", null: false
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
@@ -332,8 +331,6 @@ ActiveRecord::Schema.define(version: 20170927215609) do
     t.string "url"
     t.boolean "sensitive", default: false, null: false
     t.integer "visibility", default: 0, null: false
-    t.bigint "in_reply_to_account_id"
-    t.bigint "application_id"
     t.text "spoiler_text", default: "", null: false
     t.boolean "reply", default: false, null: false
     t.integer "favourites_count", default: 0, null: false
@@ -341,6 +338,9 @@ ActiveRecord::Schema.define(version: 20170927215609) do
     t.string "language"
     t.bigint "conversation_id"
     t.boolean "local"
+    t.bigint "account_id", null: false
+    t.bigint "application_id"
+    t.bigint "in_reply_to_account_id"
     t.index ["account_id", "id"], name: "index_statuses_on_account_id_id"
     t.index ["conversation_id"], name: "index_statuses_on_conversation_id"
     t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id"
@@ -356,12 +356,12 @@ ActiveRecord::Schema.define(version: 20170927215609) do
   end
 
   create_table "stream_entries", force: :cascade do |t|
-    t.bigint "account_id"
     t.bigint "activity_id"
     t.string "activity_type"
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
     t.boolean "hidden", default: false, null: false
+    t.bigint "account_id"
     t.index ["account_id"], name: "index_stream_entries_on_account_id"
     t.index ["activity_id", "activity_type"], name: "index_stream_entries_on_activity_id_and_activity_type"
   end
@@ -371,11 +371,11 @@ ActiveRecord::Schema.define(version: 20170927215609) do
     t.string "secret"
     t.datetime "expires_at"
     t.boolean "confirmed", default: false, null: false
-    t.bigint "account_id", null: false
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
     t.datetime "last_successful_delivery_at"
     t.string "domain"
+    t.bigint "account_id", null: false
     t.index ["account_id", "callback_url"], name: "index_subscriptions_on_account_id_and_callback_url", unique: true
   end
 
@@ -389,7 +389,6 @@ ActiveRecord::Schema.define(version: 20170927215609) do
 
   create_table "users", force: :cascade do |t|
     t.string "email", default: "", null: false
-    t.bigint "account_id", null: false
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
     t.string "encrypted_password", default: "", null: false
@@ -415,6 +414,7 @@ ActiveRecord::Schema.define(version: 20170927215609) do
     t.datetime "last_emailed_at"
     t.string "otp_backup_codes", array: true
     t.string "filtered_languages", default: [], null: false, array: true
+    t.bigint "account_id", null: false
     t.index ["account_id"], name: "index_users_on_account_id"
     t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
     t.index ["email"], name: "index_users_on_email", unique: true
@@ -432,53 +432,53 @@ ActiveRecord::Schema.define(version: 20170927215609) do
   end
 
   create_table "web_settings", force: :cascade do |t|
-    t.bigint "user_id"
     t.json "data"
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
+    t.bigint "user_id"
     t.index ["user_id"], name: "index_web_settings_on_user_id", unique: true
   end
 
-  add_foreign_key "account_domain_blocks", "accounts", on_delete: :cascade
-  add_foreign_key "blocks", "accounts", column: "target_account_id", on_delete: :cascade
-  add_foreign_key "blocks", "accounts", on_delete: :cascade
-  add_foreign_key "conversation_mutes", "accounts", on_delete: :cascade
+  add_foreign_key "account_domain_blocks", "accounts", name: "fk_206c6029bd", on_delete: :cascade
+  add_foreign_key "blocks", "accounts", column: "target_account_id", name: "fk_9571bfabc1", on_delete: :cascade
+  add_foreign_key "blocks", "accounts", name: "fk_4269e03e65", on_delete: :cascade
+  add_foreign_key "conversation_mutes", "accounts", name: "fk_225b4212bb", on_delete: :cascade
   add_foreign_key "conversation_mutes", "conversations", on_delete: :cascade
-  add_foreign_key "favourites", "accounts", on_delete: :cascade
-  add_foreign_key "favourites", "statuses", on_delete: :cascade
-  add_foreign_key "follow_requests", "accounts", column: "target_account_id", on_delete: :cascade
-  add_foreign_key "follow_requests", "accounts", on_delete: :cascade
-  add_foreign_key "follows", "accounts", column: "target_account_id", on_delete: :cascade
-  add_foreign_key "follows", "accounts", on_delete: :cascade
-  add_foreign_key "imports", "accounts", on_delete: :cascade
-  add_foreign_key "media_attachments", "accounts", on_delete: :nullify
+  add_foreign_key "favourites", "accounts", name: "fk_5eb6c2b873", on_delete: :cascade
+  add_foreign_key "favourites", "statuses", name: "fk_b0e856845e", on_delete: :cascade
+  add_foreign_key "follow_requests", "accounts", column: "target_account_id", name: "fk_9291ec025d", on_delete: :cascade
+  add_foreign_key "follow_requests", "accounts", name: "fk_76d644b0e7", on_delete: :cascade
+  add_foreign_key "follows", "accounts", column: "target_account_id", name: "fk_745ca29eac", on_delete: :cascade
+  add_foreign_key "follows", "accounts", name: "fk_32ed1b5560", on_delete: :cascade
+  add_foreign_key "imports", "accounts", name: "fk_6db1b6e408", on_delete: :cascade
+  add_foreign_key "media_attachments", "accounts", name: "fk_96dd81e81b", on_delete: :nullify
   add_foreign_key "media_attachments", "statuses", on_delete: :nullify
-  add_foreign_key "mentions", "accounts", on_delete: :cascade
+  add_foreign_key "mentions", "accounts", name: "fk_970d43f9d1", on_delete: :cascade
   add_foreign_key "mentions", "statuses", on_delete: :cascade
-  add_foreign_key "mutes", "accounts", column: "target_account_id", on_delete: :cascade
-  add_foreign_key "mutes", "accounts", on_delete: :cascade
-  add_foreign_key "notifications", "accounts", column: "from_account_id", on_delete: :cascade
-  add_foreign_key "notifications", "accounts", on_delete: :cascade
-  add_foreign_key "oauth_access_grants", "oauth_applications", column: "application_id", on_delete: :cascade
-  add_foreign_key "oauth_access_grants", "users", column: "resource_owner_id", on_delete: :cascade
-  add_foreign_key "oauth_access_tokens", "oauth_applications", column: "application_id", on_delete: :cascade
-  add_foreign_key "oauth_access_tokens", "users", column: "resource_owner_id", on_delete: :cascade
-  add_foreign_key "oauth_applications", "users", column: "owner_id", on_delete: :cascade
-  add_foreign_key "reports", "accounts", column: "action_taken_by_account_id", on_delete: :nullify
-  add_foreign_key "reports", "accounts", column: "target_account_id", on_delete: :cascade
-  add_foreign_key "reports", "accounts", on_delete: :cascade
-  add_foreign_key "session_activations", "oauth_access_tokens", column: "access_token_id", on_delete: :cascade
-  add_foreign_key "session_activations", "users", on_delete: :cascade
-  add_foreign_key "status_pins", "accounts", on_delete: :cascade
+  add_foreign_key "mutes", "accounts", column: "target_account_id", name: "fk_eecff219ea", on_delete: :cascade
+  add_foreign_key "mutes", "accounts", name: "fk_b8d8daf315", on_delete: :cascade
+  add_foreign_key "notifications", "accounts", column: "from_account_id", name: "fk_fbd6b0bf9e", on_delete: :cascade
+  add_foreign_key "notifications", "accounts", name: "fk_c141c8ee55", on_delete: :cascade
+  add_foreign_key "oauth_access_grants", "oauth_applications", column: "application_id", name: "fk_34d54b0a33", on_delete: :cascade
+  add_foreign_key "oauth_access_grants", "users", column: "resource_owner_id", name: "fk_63b044929b", on_delete: :cascade
+  add_foreign_key "oauth_access_tokens", "oauth_applications", column: "application_id", name: "fk_f5fc4c1ee3", on_delete: :cascade
+  add_foreign_key "oauth_access_tokens", "users", column: "resource_owner_id", name: "fk_e84df68546", on_delete: :cascade
+  add_foreign_key "oauth_applications", "users", column: "owner_id", name: "fk_b0988c7c0a", on_delete: :cascade
+  add_foreign_key "reports", "accounts", column: "action_taken_by_account_id", name: "fk_bca45b75fd", on_delete: :nullify
+  add_foreign_key "reports", "accounts", column: "target_account_id", name: "fk_eb37af34f0", on_delete: :cascade
+  add_foreign_key "reports", "accounts", name: "fk_4b81f7522c", on_delete: :cascade
+  add_foreign_key "session_activations", "oauth_access_tokens", column: "access_token_id", name: "fk_957e5bda89", on_delete: :cascade
+  add_foreign_key "session_activations", "users", name: "fk_e5fda67334", on_delete: :cascade
+  add_foreign_key "status_pins", "accounts", name: "fk_d4cb435b62", on_delete: :cascade
   add_foreign_key "status_pins", "statuses", on_delete: :cascade
-  add_foreign_key "statuses", "accounts", column: "in_reply_to_account_id", on_delete: :nullify
-  add_foreign_key "statuses", "accounts", on_delete: :cascade
+  add_foreign_key "statuses", "accounts", column: "in_reply_to_account_id", name: "fk_c7fa917661", on_delete: :nullify
+  add_foreign_key "statuses", "accounts", name: "fk_9bda1543f7", on_delete: :cascade
   add_foreign_key "statuses", "statuses", column: "in_reply_to_id", on_delete: :nullify
   add_foreign_key "statuses", "statuses", column: "reblog_of_id", on_delete: :cascade
   add_foreign_key "statuses_tags", "statuses", on_delete: :cascade
-  add_foreign_key "statuses_tags", "tags", on_delete: :cascade
-  add_foreign_key "stream_entries", "accounts", on_delete: :cascade
-  add_foreign_key "subscriptions", "accounts", on_delete: :cascade
-  add_foreign_key "users", "accounts", on_delete: :cascade
-  add_foreign_key "web_settings", "users", on_delete: :cascade
+  add_foreign_key "statuses_tags", "tags", name: "fk_3081861e21", on_delete: :cascade
+  add_foreign_key "stream_entries", "accounts", name: "fk_5659b17554", on_delete: :cascade
+  add_foreign_key "subscriptions", "accounts", name: "fk_9847d1cbb5", on_delete: :cascade
+  add_foreign_key "users", "accounts", name: "fk_50500f500d", on_delete: :cascade
+  add_foreign_key "web_settings", "users", name: "fk_11910667b2", on_delete: :cascade
 end