Skip to content

Commit 825c056

Browse files
zundahiyuki2578
authored andcommitted
List columns within the method (mastodon#11377)
To avoid the exception: NoMethodError: undefined method `perform' for nil:NilClass .../vendor/bundle/ruby/2.6.0/gems/strong_migrations-0.4.1/lib/strong_migrations/migration.rb:14:in `method_missing' .../vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.3/lib/active_record/migration.rb:604:in `method_missing' .../db/migrate/20170918125918_ids_to_bigints.rb:69:in `<class:IdsToBigints>' .../db/migrate/20170918125918_ids_to_bigints.rb:3:in `<top (required)>'
1 parent 856fea2 commit 825c056

1 file changed

Lines changed: 65 additions & 65 deletions

File tree

db/migrate/20170918125918_ids_to_bigints.rb

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -5,70 +5,70 @@ class IdsToBigints < ActiveRecord::Migration[5.1]
55

66
disable_ddl_transaction!
77

8-
INCLUDED_COLUMNS = [
9-
[:account_domain_blocks, :account_id],
10-
[:account_domain_blocks, :id],
11-
[:accounts, :id],
12-
[:blocks, :account_id],
13-
[:blocks, :id],
14-
[:blocks, :target_account_id],
15-
[:conversation_mutes, :account_id],
16-
[:conversation_mutes, :id],
17-
[:domain_blocks, :id],
18-
[:favourites, :account_id],
19-
[:favourites, :id],
20-
[:favourites, :status_id],
21-
[:follow_requests, :account_id],
22-
[:follow_requests, :id],
23-
[:follow_requests, :target_account_id],
24-
[:follows, :account_id],
25-
[:follows, :id],
26-
[:follows, :target_account_id],
27-
[:imports, :account_id],
28-
[:imports, :id],
29-
[:media_attachments, :account_id],
30-
[:media_attachments, :id],
31-
[:mentions, :account_id],
32-
[:mentions, :id],
33-
[:mutes, :account_id],
34-
[:mutes, :id],
35-
[:mutes, :target_account_id],
36-
[:notifications, :account_id],
37-
[:notifications, :from_account_id],
38-
[:notifications, :id],
39-
[:oauth_access_grants, :application_id],
40-
[:oauth_access_grants, :id],
41-
[:oauth_access_grants, :resource_owner_id],
42-
[:oauth_access_tokens, :application_id],
43-
[:oauth_access_tokens, :id],
44-
[:oauth_access_tokens, :resource_owner_id],
45-
[:oauth_applications, :id],
46-
[:oauth_applications, :owner_id],
47-
[:reports, :account_id],
48-
[:reports, :action_taken_by_account_id],
49-
[:reports, :id],
50-
[:reports, :target_account_id],
51-
[:session_activations, :access_token_id],
52-
[:session_activations, :user_id],
53-
[:session_activations, :web_push_subscription_id],
54-
[:settings, :id],
55-
[:settings, :thing_id],
56-
[:statuses, :account_id],
57-
[:statuses, :application_id],
58-
[:statuses, :in_reply_to_account_id],
59-
[:stream_entries, :account_id],
60-
[:stream_entries, :id],
61-
[:subscriptions, :account_id],
62-
[:subscriptions, :id],
63-
[:tags, :id],
64-
[:users, :account_id],
65-
[:users, :id],
66-
[:web_settings, :id],
67-
[:web_settings, :user_id],
68-
]
69-
INCLUDED_COLUMNS << [:deprecated_preview_cards, :id] if table_exists?(:deprecated_preview_cards)
70-
718
def migrate_columns(to_type)
9+
included_columns = [
10+
[:account_domain_blocks, :account_id],
11+
[:account_domain_blocks, :id],
12+
[:accounts, :id],
13+
[:blocks, :account_id],
14+
[:blocks, :id],
15+
[:blocks, :target_account_id],
16+
[:conversation_mutes, :account_id],
17+
[:conversation_mutes, :id],
18+
[:domain_blocks, :id],
19+
[:favourites, :account_id],
20+
[:favourites, :id],
21+
[:favourites, :status_id],
22+
[:follow_requests, :account_id],
23+
[:follow_requests, :id],
24+
[:follow_requests, :target_account_id],
25+
[:follows, :account_id],
26+
[:follows, :id],
27+
[:follows, :target_account_id],
28+
[:imports, :account_id],
29+
[:imports, :id],
30+
[:media_attachments, :account_id],
31+
[:media_attachments, :id],
32+
[:mentions, :account_id],
33+
[:mentions, :id],
34+
[:mutes, :account_id],
35+
[:mutes, :id],
36+
[:mutes, :target_account_id],
37+
[:notifications, :account_id],
38+
[:notifications, :from_account_id],
39+
[:notifications, :id],
40+
[:oauth_access_grants, :application_id],
41+
[:oauth_access_grants, :id],
42+
[:oauth_access_grants, :resource_owner_id],
43+
[:oauth_access_tokens, :application_id],
44+
[:oauth_access_tokens, :id],
45+
[:oauth_access_tokens, :resource_owner_id],
46+
[:oauth_applications, :id],
47+
[:oauth_applications, :owner_id],
48+
[:reports, :account_id],
49+
[:reports, :action_taken_by_account_id],
50+
[:reports, :id],
51+
[:reports, :target_account_id],
52+
[:session_activations, :access_token_id],
53+
[:session_activations, :user_id],
54+
[:session_activations, :web_push_subscription_id],
55+
[:settings, :id],
56+
[:settings, :thing_id],
57+
[:statuses, :account_id],
58+
[:statuses, :application_id],
59+
[:statuses, :in_reply_to_account_id],
60+
[:stream_entries, :account_id],
61+
[:stream_entries, :id],
62+
[:subscriptions, :account_id],
63+
[:subscriptions, :id],
64+
[:tags, :id],
65+
[:users, :account_id],
66+
[:users, :id],
67+
[:web_settings, :id],
68+
[:web_settings, :user_id],
69+
]
70+
included_columns << [:deprecated_preview_cards, :id] if table_exists?(:deprecated_preview_cards)
71+
7272
# Print out a warning that this will probably take a while.
7373
say ''
7474
say 'WARNING: This migration may take a *long* time for large instances'
@@ -86,15 +86,15 @@ def migrate_columns(to_type)
8686
sleep 1
8787
end
8888

89-
tables = INCLUDED_COLUMNS.map(&:first).uniq
89+
tables = included_columns.map(&:first).uniq
9090
table_sizes = {}
9191

9292
# Sort tables by their size
9393
tables.each do |table|
9494
table_sizes[table] = estimate_rows_in_table(table)
9595
end
9696

97-
ordered_columns = INCLUDED_COLUMNS.sort_by do |col_parts|
97+
ordered_columns = included_columns.sort_by do |col_parts|
9898
[-table_sizes[col_parts.first], col_parts.last]
9999
end
100100

0 commit comments

Comments
 (0)