Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `.github/dependabot.yml`: Upstream made changes while we have dropped this file. Keep the file deleted. - `.prettierignore`: Upstream made changes at the end of the file, where we had our extra lines. Just moved our extra lines back at the end. - `app/serializers/initial_state_serializer.rb`: Upstream code style changes. Applied them. - `app/services/backup_service.rb`: Upstream code style changes. Applied them.
This commit is contained in:
@ -2,7 +2,7 @@ class AddDeviseToUsers < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
change_table(:users) do |t|
|
||||
## Database authenticatable
|
||||
t.string :encrypted_password, null: false, default: ""
|
||||
t.string :encrypted_password, null: false, default: ''
|
||||
|
||||
## Recoverable
|
||||
t.string :reset_password_token
|
||||
|
@ -1,8 +1,8 @@
|
||||
MIGRATION_BASE_CLASS = if ActiveRecord::VERSION::MAJOR >= 5
|
||||
ActiveRecord::Migration[5.0]
|
||||
else
|
||||
ActiveRecord::Migration[4.2]
|
||||
end
|
||||
ActiveRecord::Migration[5.0]
|
||||
else
|
||||
ActiveRecord::Migration[4.2]
|
||||
end
|
||||
|
||||
class RailsSettingsMigration < MIGRATION_BASE_CLASS
|
||||
def self.up
|
||||
@ -12,7 +12,7 @@ class RailsSettingsMigration < MIGRATION_BASE_CLASS
|
||||
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
|
||||
|
@ -1,7 +1,7 @@
|
||||
class RemoveUnneededIndexes < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
remove_index :notifications, name: "index_notifications_on_account_id"
|
||||
remove_index :settings, name: "index_settings_on_target_type_and_target_id"
|
||||
remove_index :statuses_tags, name: "index_statuses_tags_on_tag_id"
|
||||
remove_index :notifications, name: 'index_notifications_on_account_id'
|
||||
remove_index :settings, name: 'index_settings_on_target_type_and_target_id'
|
||||
remove_index :statuses_tags, name: 'index_statuses_tags_on_tag_id'
|
||||
end
|
||||
end
|
||||
|
@ -1,5 +1,5 @@
|
||||
class AddSpoilerTextToStatuses < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :statuses, :spoiler_text, :text, default: "", null: false
|
||||
add_column :statuses, :spoiler_text, :text, default: '', null: false
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +1,7 @@
|
||||
class AddVisibleInPickerToCustomEmoji < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
safety_assured {
|
||||
safety_assured do
|
||||
add_column :custom_emojis, :visible_in_picker, :boolean, default: true, null: false
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,6 +1,6 @@
|
||||
class RemoveDuplicateIndexesInLists < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
remove_index :list_accounts, name: "index_list_accounts_on_account_id"
|
||||
remove_index :list_accounts, name: "index_list_accounts_on_list_id"
|
||||
remove_index :list_accounts, name: 'index_list_accounts_on_account_id'
|
||||
remove_index :list_accounts, name: 'index_list_accounts_on_list_id'
|
||||
end
|
||||
end
|
||||
|
@ -4,9 +4,9 @@ class ImproveIndexOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecord::Mi
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
# These changes ware reverted by migration 20180514140000.
|
||||
# add_index :statuses, [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently
|
||||
# add_index :statuses, [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently
|
||||
# remove_index :statuses, column: [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106
|
||||
# These changes ware reverted by migration 20180514140000.
|
||||
# add_index :statuses, [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently
|
||||
# add_index :statuses, [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently
|
||||
# remove_index :statuses, column: [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106
|
||||
end
|
||||
end
|
||||
|
@ -5,11 +5,11 @@ class RevertIndexChangeOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecor
|
||||
|
||||
def change
|
||||
safety_assured do
|
||||
add_index :statuses, [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 unless index_name_exists?(:statuses, "index_statuses_20180106")
|
||||
add_index :statuses, [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 unless index_name_exists?(:statuses, 'index_statuses_20180106')
|
||||
end
|
||||
|
||||
# These index may not exists (see migration 20180514130000)
|
||||
remove_index :statuses, column: [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently if index_exists?(:statuses, [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)')
|
||||
remove_index :statuses, column: [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently if index_exists?(:statuses, ["account_id", "id"], where: "(visibility = 3)")
|
||||
remove_index :statuses, column: [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently if index_exists?(:statuses, ['account_id', 'id'], where: '(visibility = 3)')
|
||||
end
|
||||
end
|
||||
|
@ -106,21 +106,17 @@ class FixAccountsUniqueIndex < ActiveRecord::Migration[5.2]
|
||||
# to check for (and skip past) uniqueness errors
|
||||
[Favourite, Follow, FollowRequest, Block, Mute].each do |klass|
|
||||
klass.where(account_id: duplicate_account.id).find_each do |record|
|
||||
begin
|
||||
record.update_attribute(:account_id, main_account.id)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
next
|
||||
end
|
||||
record.update_attribute(:account_id, main_account.id)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
next
|
||||
end
|
||||
end
|
||||
|
||||
[Follow, FollowRequest, Block, Mute].each do |klass|
|
||||
klass.where(target_account_id: duplicate_account.id).find_each do |record|
|
||||
begin
|
||||
record.update_attribute(:target_account_id, main_account.id)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
next
|
||||
end
|
||||
record.update_attribute(:target_account_id, main_account.id)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
next
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +1,7 @@
|
||||
class RemoveUnusedIndexes < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
remove_index :statuses, name: "index_statuses_on_conversation_id"
|
||||
remove_index :users, name: "index_users_on_filtered_languages"
|
||||
remove_index :backups, name: "index_backups_on_user_id"
|
||||
remove_index :statuses, name: 'index_statuses_on_conversation_id'
|
||||
remove_index :users, name: 'index_users_on_filtered_languages'
|
||||
remove_index :backups, name: 'index_backups_on_user_id'
|
||||
end
|
||||
end
|
||||
|
@ -19,7 +19,7 @@ class CopyStatusStats < ActiveRecord::Migration[5.2]
|
||||
|
||||
def supports_upsert?
|
||||
version = select_one("SELECT current_setting('server_version_num') AS v")['v'].to_i
|
||||
version >= 90500
|
||||
version >= 90_500
|
||||
end
|
||||
|
||||
def up_fast
|
||||
@ -43,12 +43,10 @@ class CopyStatusStats < ActiveRecord::Migration[5.2]
|
||||
# We cannot use bulk INSERT or overarching transactions here because of possible
|
||||
# uniqueness violations that we need to skip over
|
||||
Status.unscoped.select('id, reblogs_count, favourites_count, created_at, updated_at').find_each do |status|
|
||||
begin
|
||||
params = [[nil, status.id], [nil, status.reblogs_count], [nil, status.favourites_count], [nil, status.created_at], [nil, status.updated_at]]
|
||||
exec_insert('INSERT INTO status_stats (status_id, reblogs_count, favourites_count, created_at, updated_at) VALUES ($1, $2, $3, $4, $5)', nil, params)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
next
|
||||
end
|
||||
params = [[nil, status.id], [nil, status.reblogs_count], [nil, status.favourites_count], [nil, status.created_at], [nil, status.updated_at]]
|
||||
exec_insert('INSERT INTO status_stats (status_id, reblogs_count, favourites_count, created_at, updated_at) VALUES ($1, $2, $3, $4, $5)', nil, params)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
next
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -19,7 +19,7 @@ class CopyAccountStats < ActiveRecord::Migration[5.2]
|
||||
|
||||
def supports_upsert?
|
||||
version = select_one("SELECT current_setting('server_version_num') AS v")['v'].to_i
|
||||
version >= 90500
|
||||
version >= 90_500
|
||||
end
|
||||
|
||||
def up_fast
|
||||
@ -43,12 +43,10 @@ class CopyAccountStats < ActiveRecord::Migration[5.2]
|
||||
# We cannot use bulk INSERT or overarching transactions here because of possible
|
||||
# uniqueness violations that we need to skip over
|
||||
Account.unscoped.select('id, statuses_count, following_count, followers_count, created_at, updated_at').find_each do |account|
|
||||
begin
|
||||
params = [[nil, account.id], [nil, account[:statuses_count]], [nil, account[:following_count]], [nil, account[:followers_count]], [nil, account.created_at], [nil, account.updated_at]]
|
||||
exec_insert('INSERT INTO account_stats (account_id, statuses_count, following_count, followers_count, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6)', nil, params)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
next
|
||||
end
|
||||
params = [[nil, account.id], [nil, account[:statuses_count]], [nil, account[:following_count]], [nil, account[:followers_count]], [nil, account.created_at], [nil, account.updated_at]]
|
||||
exec_insert('INSERT INTO account_stats (account_id, statuses_count, following_count, followers_count, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6)', nil, params)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
next
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -21,4 +21,3 @@ class AddLockVersionToPolls < ActiveRecord::Migration[5.2]
|
||||
remove_column :polls, :lock_version
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -4,4 +4,3 @@ class AddCommentsToDomainBlocks < ActiveRecord::Migration[5.2]
|
||||
add_column :domain_blocks, :public_comment, :text
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -3,4 +3,3 @@ class AddStatusIdsToAnnouncements < ActiveRecord::Migration[5.2]
|
||||
add_column :announcements, :status_ids, :bigint, array: true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -19,4 +19,3 @@ class RemoveDuplicatedIndexesPghero < ActiveRecord::Migration[5.2]
|
||||
add_index :markers, :user_id, name: :index_markers_on_user_id unless index_exists?(:markers, :user_id, name: :index_markers_on_user_id)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -6,7 +6,7 @@ class EncryptedMessageIdsToTimestampIds < ActiveRecord::Migration[5.2]
|
||||
end
|
||||
|
||||
def down
|
||||
execute("LOCK encrypted_messages")
|
||||
execute('LOCK encrypted_messages')
|
||||
execute("SELECT setval('encrypted_messages_id_seq', (SELECT MAX(id) FROM encrypted_messages))")
|
||||
execute("ALTER TABLE encrypted_messages ALTER COLUMN id SET DEFAULT nextval('encrypted_messages_id_seq')")
|
||||
end
|
||||
|
@ -16,7 +16,7 @@ class AddFixedLowercaseIndexToAccounts < ActiveRecord::Migration[5.2]
|
||||
add_index :accounts, "lower (username), COALESCE(lower(domain), '')", name: 'index_accounts_on_username_and_domain_lower', unique: true, algorithm: :concurrently
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
remove_index :accounts, name: 'index_accounts_on_username_and_domain_lower'
|
||||
raise CorruptionError.new('index_accounts_on_username_and_domain_lower')
|
||||
raise CorruptionError, 'index_accounts_on_username_and_domain_lower'
|
||||
end
|
||||
|
||||
remove_index :accounts, name: 'old_index_accounts_on_username_and_domain_lower' if index_name_exists?(:accounts, 'old_index_accounts_on_username_and_domain_lower')
|
||||
|
@ -10,7 +10,7 @@ class MediaAttachmentIdsToTimestampIds < ActiveRecord::Migration[5.1]
|
||||
end
|
||||
|
||||
def down
|
||||
execute("LOCK media_attachments")
|
||||
execute('LOCK media_attachments')
|
||||
execute("SELECT setval('media_attachments_id_seq', (SELECT MAX(id) FROM media_attachments))")
|
||||
execute("ALTER TABLE media_attachments ALTER COLUMN id SET DEFAULT nextval('media_attachments_id_seq')")
|
||||
end
|
||||
|
@ -10,4 +10,3 @@ class CreateAccountNotes < ActiveRecord::Migration[5.2]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -10,7 +10,7 @@ class AccountIdsToTimestampIds < ActiveRecord::Migration[5.1]
|
||||
end
|
||||
|
||||
def down
|
||||
execute("LOCK accounts")
|
||||
execute('LOCK accounts')
|
||||
execute("SELECT setval('accounts_id_seq', (SELECT MAX(id) FROM accounts))")
|
||||
execute("ALTER TABLE accounts ALTER COLUMN id SET DEFAULT nextval('accounts_id_seq')")
|
||||
end
|
||||
|
@ -10,7 +10,7 @@ class AddCaseInsensitiveBtreeIndexToTags < ActiveRecord::Migration[5.2]
|
||||
safety_assured { execute 'CREATE UNIQUE INDEX CONCURRENTLY index_tags_on_name_lower_btree ON tags (lower(name) text_pattern_ops)' }
|
||||
rescue ActiveRecord::StatementInvalid => e
|
||||
remove_index :tags, name: 'index_tags_on_name_lower_btree'
|
||||
raise CorruptionError.new('index_tags_on_name_lower_btree') if e.is_a?(ActiveRecord::RecordNotUnique)
|
||||
raise CorruptionError, 'index_tags_on_name_lower_btree' if e.is_a?(ActiveRecord::RecordNotUnique)
|
||||
raise e
|
||||
end
|
||||
|
||||
|
@ -17,4 +17,3 @@ class CreateAccountStatusesCleanupPolicies < ActiveRecord::Migration[6.1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -5,7 +5,7 @@ class FixCustomFilterKeywordsIdSeq < ActiveRecord::Migration[6.1]
|
||||
|
||||
def up
|
||||
# 20220613110711 manually inserts items with set `id` in the database, but
|
||||
# we also need to bump the sequence number, otherwise
|
||||
# we also need to bump the sequence number, otherwise
|
||||
safety_assured do
|
||||
execute <<-SQL.squish
|
||||
BEGIN;
|
||||
|
Reference in New Issue
Block a user