Merge branch 'main' into glitch-soc/merge-upstream

This commit is contained in:
Claire
2021-03-19 13:57:15 +01:00
63 changed files with 408 additions and 398 deletions

View File

@@ -1,4 +1,4 @@
class AddUrlToStatuses < ActiveRecord::Migration[4.2]
class AddURLToStatuses < ActiveRecord::Migration[4.2]
def change
add_column :statuses, :url, :string, null: true, default: nil
end

View File

@@ -1,4 +1,4 @@
class AddUrlToAccounts < ActiveRecord::Migration[4.2]
class AddURLToAccounts < ActiveRecord::Migration[4.2]
def change
add_column :accounts, :url, :string, null: true, default: nil
end

View File

@@ -1,4 +1,4 @@
class AddAvatarRemoteUrlToAccounts < ActiveRecord::Migration[4.2]
class AddAvatarRemoteURLToAccounts < ActiveRecord::Migration[4.2]
def change
add_column :accounts, :avatar_remote_url, :string, null: true, default: nil
end

View File

@@ -7,12 +7,12 @@ end
class RailsSettingsMigration < MIGRATION_BASE_CLASS
def self.up
create_table :settings do |t|
t.string :var, :null => false
t.string :var, null: false
t.text :value
t.references :target, :null => false, :polymorphic => true
t.timestamps :null => true
t.references :target, null: false, polymorphic: true, index: { name: 'index_settings_on_target_type_and_target_id' }
t.timestamps null: true
end
add_index :settings, [ :target_type, :target_id, :var ], :unique => true
add_index :settings, [ :target_type, :target_id, :var ], unique: true
end
def self.down

View File

@@ -1,4 +1,4 @@
class AddHeaderRemoteUrlToAccounts < ActiveRecord::Migration[5.0]
class AddHeaderRemoteURLToAccounts < ActiveRecord::Migration[5.0]
def change
add_column :accounts, :header_remote_url, :string, null: false, default: ''
end

View File

@@ -1,7 +1,7 @@
class StatusIdsToTimestampIds < ActiveRecord::Migration[5.1]
def up
# Prepare the function we will use to generate IDs.
Rake::Task['db:define_timestamp_id'].execute
Mastodon::Snowflake.define_timestamp_id
# Set up the statuses.id column to use our timestamp-based IDs.
ActiveRecord::Base.connection.execute(<<~SQL)
@@ -11,7 +11,7 @@ class StatusIdsToTimestampIds < ActiveRecord::Migration[5.1]
SQL
# Make sure we have a sequence to use.
Rake::Task['db:ensure_id_sequences_exist'].execute
Mastodon::Snowflake.ensure_id_sequences_exist
end
def down

View File

@@ -3,7 +3,7 @@ class CreateAdminActionLogs < ActiveRecord::Migration[5.1]
create_table :admin_action_logs do |t|
t.belongs_to :account, foreign_key: { on_delete: :cascade }
t.string :action, null: false, default: ''
t.references :target, polymorphic: true
t.references :target, polymorphic: true, index: { name: 'index_admin_action_logs_on_target_type_and_target_id' }
t.text :recorded_changes, null: false, default: ''
t.timestamps

View File

@@ -1,6 +1,6 @@
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddEmbedUrlToPreviewCards < ActiveRecord::Migration[5.1]
class AddEmbedURLToPreviewCards < ActiveRecord::Migration[5.1]
include Mastodon::MigrationHelpers
disable_ddl_transaction!

View File

@@ -1,4 +1,4 @@
class AddFeaturedCollectionUrlToAccounts < ActiveRecord::Migration[5.1]
class AddFeaturedCollectionURLToAccounts < ActiveRecord::Migration[5.1]
def change
add_column :accounts, :featured_collection_url, :string
end

View File

@@ -37,7 +37,7 @@ class FixAccountsUniqueIndex < ActiveRecord::Migration[5.2]
end
end
duplicates = Account.connection.select_all('SELECT string_agg(id::text, \',\') AS ids FROM accounts GROUP BY lower(username), lower(domain) HAVING count(*) > 1').to_hash
duplicates = Account.connection.select_all('SELECT string_agg(id::text, \',\') AS ids FROM accounts GROUP BY lower(username), lower(domain) HAVING count(*) > 1').to_ary
duplicates.each do |row|
deduplicate_account!(row['ids'].split(','))

View File

@@ -17,8 +17,8 @@ class MigrateAccountConversations < ActiveRecord::Migration[5.2]
belongs_to :account, optional: true
belongs_to :activity, polymorphic: true, optional: true
belongs_to :status, foreign_type: 'Status', foreign_key: 'activity_id', optional: true
belongs_to :mention, foreign_type: 'Mention', foreign_key: 'activity_id', optional: true
belongs_to :status, foreign_key: 'activity_id', optional: true
belongs_to :mention, foreign_key: 'activity_id', optional: true
def target_status
mention&.status

View File

@@ -2,7 +2,7 @@ class DowncaseCustomEmojiDomains < ActiveRecord::Migration[5.2]
disable_ddl_transaction!
def up
duplicates = CustomEmoji.connection.select_all('SELECT string_agg(id::text, \',\') AS ids FROM custom_emojis GROUP BY shortcode, lower(domain) HAVING count(*) > 1').to_hash
duplicates = CustomEmoji.connection.select_all('SELECT string_agg(id::text, \',\') AS ids FROM custom_emojis GROUP BY shortcode, lower(domain) HAVING count(*) > 1').to_ary
duplicates.each do |row|
CustomEmoji.where(id: row['ids'].split(',')[0...-1]).destroy_all

View File

@@ -2,7 +2,7 @@ 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|
Tag.connection.select_all('SELECT string_agg(id::text, \',\') AS ids FROM tags GROUP BY lower(name) HAVING count(*) > 1').to_ary.each do |row|
canonical_tag_id = row['ids'].split(',').first
redundant_tag_ids = row['ids'].split(',')[1..-1]

View File

@@ -1,4 +1,4 @@
class AddDevicesUrlToAccounts < ActiveRecord::Migration[5.2]
class AddDevicesURLToAccounts < ActiveRecord::Migration[5.2]
def change
add_column :accounts, :devices_url, :string
end