From dd4ef69839c78e4220cd821bc3ad369eb6e41fa7 Mon Sep 17 00:00:00 2001 From: aschmitz Date: Fri, 22 Sep 2017 06:20:04 -0500 Subject: Hardcode IdToBigints migration columns (#5039) This addresses a comment during review: https://github.com/tootsuite/mastodon/pull/4801#discussion_r139337452 This means we'll need to make sure that all _id columns going forward are bigints, but that should happen automatically in most cases. --- db/migrate/20170918125918_ids_to_bigints.rb | 127 ++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 db/migrate/20170918125918_ids_to_bigints.rb (limited to 'db/migrate') diff --git a/db/migrate/20170918125918_ids_to_bigints.rb b/db/migrate/20170918125918_ids_to_bigints.rb new file mode 100644 index 000000000..9c81ecc05 --- /dev/null +++ b/db/migrate/20170918125918_ids_to_bigints.rb @@ -0,0 +1,127 @@ +class IdsToBigints < ActiveRecord::Migration[5.1] + 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 + 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 + 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 + 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 + end +end -- cgit From dcfc9b220462533c8bcdebc7ca25a68fa23aaf5f Mon Sep 17 00:00:00 2001 From: nullkal Date: Sat, 23 Sep 2017 02:32:57 +0900 Subject: Fix the migration error when deprecated_preview_cards has been deleted (#5043) * Fix the migration error when deprecated_preview_cards has deleted * Re-run Travis CI --- db/migrate/20170918125918_ids_to_bigints.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db/migrate') diff --git a/db/migrate/20170918125918_ids_to_bigints.rb b/db/migrate/20170918125918_ids_to_bigints.rb index 9c81ecc05..7483dd77a 100644 --- a/db/migrate/20170918125918_ids_to_bigints.rb +++ b/db/migrate/20170918125918_ids_to_bigints.rb @@ -8,7 +8,7 @@ class IdsToBigints < ActiveRecord::Migration[5.1] 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 + 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 @@ -71,7 +71,7 @@ class IdsToBigints < ActiveRecord::Migration[5.1] 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 + 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 -- cgit From b2820c3913266711716c6d91b2198d964881dbba Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 24 Sep 2017 05:58:07 +0200 Subject: Forgotten in #5039, change statuses_tags tag_id to bigint (#5070) --- db/migrate/20170924022025_ids_to_bigints2.rb | 9 +++++++++ db/schema.rb | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170924022025_ids_to_bigints2.rb (limited to 'db/migrate') diff --git a/db/migrate/20170924022025_ids_to_bigints2.rb b/db/migrate/20170924022025_ids_to_bigints2.rb new file mode 100644 index 000000000..db8ccd919 --- /dev/null +++ b/db/migrate/20170924022025_ids_to_bigints2.rb @@ -0,0 +1,9 @@ +class IdsToBigints2 < ActiveRecord::Migration[5.1] + def up + change_column :statuses_tags, :tag_id, :bigint + end + + def down + change_column :statuses_tags, :tag_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index cf4edf9e5..e16599d32 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170918125918) do +ActiveRecord::Schema.define(version: 20170924022025) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit