Merge tag 'v3.0.1' into instance_only_statuses
This commit is contained in:
@ -3,7 +3,7 @@ class AddInReplyToAccountIdToStatuses < ActiveRecord::Migration[5.0]
|
||||
add_column :statuses, :in_reply_to_account_id, :integer, null: true, default: nil
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
Status.where.not(in_reply_to_id: nil).includes(:thread).find_each do |status|
|
||||
Status.unscoped.where.not(in_reply_to_id: nil).includes(:thread).find_each do |status|
|
||||
next if status.thread.nil?
|
||||
|
||||
status.in_reply_to_account_id = status.thread.account_id
|
||||
|
@ -1,7 +1,7 @@
|
||||
class AddReplyToStatuses < ActiveRecord::Migration[5.0]
|
||||
def up
|
||||
add_column :statuses, :reply, :boolean, nil: false, default: false
|
||||
Status.update_all('reply = (in_reply_to_id IS NOT NULL)')
|
||||
Status.unscoped.update_all('reply = (in_reply_to_id IS NOT NULL)')
|
||||
end
|
||||
|
||||
def down
|
||||
|
@ -5,70 +5,70 @@ class IdsToBigints < ActiveRecord::Migration[5.1]
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
# Print out a warning that this will probably take a while.
|
||||
say ''
|
||||
say 'WARNING: This migration may take a *long* time for large instances'
|
||||
@ -86,7 +86,7 @@ class IdsToBigints < ActiveRecord::Migration[5.1]
|
||||
sleep 1
|
||||
end
|
||||
|
||||
tables = INCLUDED_COLUMNS.map(&:first).uniq
|
||||
tables = included_columns.map(&:first).uniq
|
||||
table_sizes = {}
|
||||
|
||||
# Sort tables by their size
|
||||
@ -94,7 +94,7 @@ class IdsToBigints < ActiveRecord::Migration[5.1]
|
||||
table_sizes[table] = estimate_rows_in_table(table)
|
||||
end
|
||||
|
||||
ordered_columns = INCLUDED_COLUMNS.sort_by do |col_parts|
|
||||
ordered_columns = included_columns.sort_by do |col_parts|
|
||||
[-table_sizes[col_parts.first], col_parts.last]
|
||||
end
|
||||
|
||||
|
@ -12,6 +12,11 @@ class FixAccountsUniqueIndex < ActiveRecord::Migration[5.2]
|
||||
end
|
||||
end
|
||||
|
||||
class StreamEntry < ApplicationRecord
|
||||
# Dummy class, to make migration possible across version changes
|
||||
belongs_to :account, inverse_of: :stream_entries
|
||||
end
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
|
@ -52,6 +52,6 @@ class MigrateAccountConversations < ActiveRecord::Migration[5.2]
|
||||
end
|
||||
|
||||
def notifications_about_direct_statuses
|
||||
Notification.joins(mention: :status).where(activity_type: 'Mention', statuses: { visibility: :direct })
|
||||
Notification.joins('INNER JOIN mentions ON mentions.id = notifications.activity_id INNER JOIN statuses ON statuses.id = mentions.status_id').where(activity_type: 'Mention', statuses: { visibility: :direct })
|
||||
end
|
||||
end
|
||||
|
5
db/migrate/20190403141604_add_comment_to_invites.rb
Normal file
5
db/migrate/20190403141604_add_comment_to_invites.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddCommentToInvites < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :invites, :comment, :text
|
||||
end
|
||||
end
|
@ -0,0 +1,9 @@
|
||||
class CreateCustomEmojiCategories < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :custom_emoji_categories do |t|
|
||||
t.string :name, index: { unique: true }
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddCategoryIdToCustomEmojis < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :custom_emojis, :category_id, :bigint
|
||||
end
|
||||
end
|
5
db/migrate/20190701022101_add_trust_level_to_accounts.rb
Normal file
5
db/migrate/20190701022101_add_trust_level_to_accounts.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddTrustLevelToAccounts < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :accounts, :trust_level, :integer
|
||||
end
|
||||
end
|
9
db/migrate/20190705002136_create_domain_allows.rb
Normal file
9
db/migrate/20190705002136_create_domain_allows.rb
Normal file
@ -0,0 +1,9 @@
|
||||
class CreateDomainAllows < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :domain_allows do |t|
|
||||
t.string :domain, default: '', null: false, index: { unique: true }
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
9
db/migrate/20190715164535_add_instance_actor.rb
Normal file
9
db/migrate/20190715164535_add_instance_actor.rb
Normal file
@ -0,0 +1,9 @@
|
||||
class AddInstanceActor < ActiveRecord::Migration[5.2]
|
||||
def up
|
||||
Account.create!(id: -99, actor_type: 'Application', locked: true, username: Rails.configuration.x.local_domain)
|
||||
end
|
||||
|
||||
def down
|
||||
Account.find_by(id: -99, actor_type: 'Application').destroy!
|
||||
end
|
||||
end
|
@ -0,0 +1,28 @@
|
||||
class AddCaseInsensitiveIndexToTags < ActiveRecord::Migration[5.2]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
Tag.connection.select_all('SELECT string_agg(id::text, \',\') AS ids FROM tags GROUP BY lower(name) HAVING count(*) > 1').to_hash.each do |row|
|
||||
canonical_tag_id = row['ids'].split(',').first
|
||||
redundant_tag_ids = row['ids'].split(',')[1..-1]
|
||||
|
||||
safety_assured do
|
||||
execute "UPDATE accounts_tags AS t0 SET tag_id = #{canonical_tag_id} WHERE tag_id IN (#{redundant_tag_ids.join(', ')}) AND NOT EXISTS (SELECT t1.tag_id FROM accounts_tags AS t1 WHERE t1.tag_id = #{canonical_tag_id} AND t1.account_id = t0.account_id)"
|
||||
execute "UPDATE statuses_tags AS t0 SET tag_id = #{canonical_tag_id} WHERE tag_id IN (#{redundant_tag_ids.join(', ')}) AND NOT EXISTS (SELECT t1.tag_id FROM statuses_tags AS t1 WHERE t1.tag_id = #{canonical_tag_id} AND t1.status_id = t0.status_id)"
|
||||
execute "UPDATE featured_tags AS t0 SET tag_id = #{canonical_tag_id} WHERE tag_id IN (#{redundant_tag_ids.join(', ')}) AND NOT EXISTS (SELECT t1.tag_id FROM featured_tags AS t1 WHERE t1.tag_id = #{canonical_tag_id} AND t1.account_id = t0.account_id)"
|
||||
end
|
||||
|
||||
Tag.where(id: redundant_tag_ids).in_batches.delete_all
|
||||
end
|
||||
|
||||
safety_assured { execute 'CREATE UNIQUE INDEX CONCURRENTLY index_tags_on_name_lower ON tags (lower(name))' }
|
||||
remove_index :tags, name: 'index_tags_on_name'
|
||||
remove_index :tags, name: 'hashtag_search_index'
|
||||
end
|
||||
|
||||
def down
|
||||
add_index :tags, :name, unique: true, algorithm: :concurrently
|
||||
safety_assured { execute 'CREATE INDEX CONCURRENTLY hashtag_search_index ON tags (name text_pattern_ops)' }
|
||||
remove_index :tags, name: 'index_tags_on_name_lower'
|
||||
end
|
||||
end
|
5
db/migrate/20190729185330_add_score_to_tags.rb
Normal file
5
db/migrate/20190729185330_add_score_to_tags.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddScoreToTags < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :tags, :score, :int
|
||||
end
|
||||
end
|
9
db/migrate/20190805123746_add_capabilities_to_tags.rb
Normal file
9
db/migrate/20190805123746_add_capabilities_to_tags.rb
Normal file
@ -0,0 +1,9 @@
|
||||
class AddCapabilitiesToTags < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :tags, :usable, :boolean
|
||||
add_column :tags, :trendable, :boolean
|
||||
add_column :tags, :listable, :boolean
|
||||
add_column :tags, :reviewed_at, :datetime
|
||||
add_column :tags, :requested_review_at, :datetime
|
||||
end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
class AddCommentsToDomainBlocks < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :domain_blocks, :private_comment, :text
|
||||
add_column :domain_blocks, :public_comment, :text
|
||||
end
|
||||
end
|
||||
|
6
db/migrate/20190815225426_add_last_status_at_to_tags.rb
Normal file
6
db/migrate/20190815225426_add_last_status_at_to_tags.rb
Normal file
@ -0,0 +1,6 @@
|
||||
class AddLastStatusAtToTags < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :tags, :last_status_at, :datetime
|
||||
add_column :tags, :last_trend_at, :datetime
|
||||
end
|
||||
end
|
5
db/migrate/20190819134503_add_deleted_at_to_statuses.rb
Normal file
5
db/migrate/20190819134503_add_deleted_at_to_statuses.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddDeletedAtToStatuses < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :statuses, :deleted_at, :datetime
|
||||
end
|
||||
end
|
13
db/migrate/20190820003045_update_statuses_index.rb
Normal file
13
db/migrate/20190820003045_update_statuses_index.rb
Normal file
@ -0,0 +1,13 @@
|
||||
class UpdateStatusesIndex < ActiveRecord::Migration[5.2]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
safety_assured { add_index :statuses, [:account_id, :id, :visibility, :updated_at], where: 'deleted_at IS NULL', order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20190820 }
|
||||
remove_index :statuses, name: :index_statuses_20180106
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured { add_index :statuses, [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 }
|
||||
remove_index :statuses, name: :index_statuses_20190820
|
||||
end
|
||||
end
|
11
db/migrate/20190823221802_add_local_index_to_statuses.rb
Normal file
11
db/migrate/20190823221802_add_local_index_to_statuses.rb
Normal file
@ -0,0 +1,11 @@
|
||||
class AddLocalIndexToStatuses < ActiveRecord::Migration[5.2]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_index :statuses, [:id, :account_id], name: :index_statuses_local_20190824, algorithm: :concurrently, 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))'
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :statuses, name: :index_statuses_local_20190824
|
||||
end
|
||||
end
|
6
db/migrate/20190901035623_add_max_score_to_tags.rb
Normal file
6
db/migrate/20190901035623_add_max_score_to_tags.rb
Normal file
@ -0,0 +1,6 @@
|
||||
class AddMaxScoreToTags < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :tags, :max_score, :float
|
||||
add_column :tags, :max_score_at, :datetime
|
||||
end
|
||||
end
|
14
db/migrate/20190904222339_create_markers.rb
Normal file
14
db/migrate/20190904222339_create_markers.rb
Normal file
@ -0,0 +1,14 @@
|
||||
class CreateMarkers < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :markers do |t|
|
||||
t.references :user, foreign_key: { on_delete: :cascade, index: false }
|
||||
t.string :timeline, default: '', null: false
|
||||
t.bigint :last_read_id, default: 0, null: false
|
||||
t.integer :lock_version, default: 0, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :markers, [:user_id, :timeline], unique: true
|
||||
end
|
||||
end
|
12
db/migrate/20190914202517_create_account_migrations.rb
Normal file
12
db/migrate/20190914202517_create_account_migrations.rb
Normal file
@ -0,0 +1,12 @@
|
||||
class CreateAccountMigrations < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :account_migrations do |t|
|
||||
t.belongs_to :account, foreign_key: { on_delete: :cascade }
|
||||
t.string :acct, null: false, default: ''
|
||||
t.bigint :followers_count, null: false, default: 0
|
||||
t.belongs_to :target_account, foreign_key: { to_table: :accounts, on_delete: :nullify }
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
11
db/migrate/20190915194355_create_account_aliases.rb
Normal file
11
db/migrate/20190915194355_create_account_aliases.rb
Normal file
@ -0,0 +1,11 @@
|
||||
class CreateAccountAliases < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :account_aliases do |t|
|
||||
t.belongs_to :account, foreign_key: { on_delete: :cascade }
|
||||
t.string :acct, null: false, default: ''
|
||||
t.string :uri, null: false, default: ''
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
9
db/migrate/20190917213523_add_remember_token_index.rb
Normal file
9
db/migrate/20190917213523_add_remember_token_index.rb
Normal file
@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddRememberTokenIndex < ActiveRecord::Migration[5.2]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
add_index :users, :remember_token, algorithm: :concurrently, unique: true
|
||||
end
|
||||
end
|
5
db/migrate/20190927232842_add_voters_count_to_polls.rb
Normal file
5
db/migrate/20190927232842_add_voters_count_to_polls.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddVotersCountToPolls < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :polls, :voters_count, :bigint
|
||||
end
|
||||
end
|
@ -0,0 +1,15 @@
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class AddLockVersionToAccountStats < ActiveRecord::Migration[5.2]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
safety_assured { add_column_with_default :account_stats, :lock_version, :integer, allow_null: false, default: 0 }
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :account_stats, :lock_version
|
||||
end
|
||||
end
|
11
db/migrate/20191007013357_update_pt_locales.rb
Normal file
11
db/migrate/20191007013357_update_pt_locales.rb
Normal file
@ -0,0 +1,11 @@
|
||||
class UpdatePtLocales < ActiveRecord::Migration[5.2]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
User.where(locale: 'pt').in_batches.update_all(locale: 'pt-PT')
|
||||
end
|
||||
|
||||
def down
|
||||
User.where(locale: 'pt-PT').in_batches.update_all(locale: 'pt')
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user