0
0
Fork 0

Remove add_column_with_default migration helper (#28654)

This commit is contained in:
Matt Jankowski 2024-01-10 05:35:06 -05:00 committed by GitHub
parent 36b46ea3b5
commit ea1c0feb86
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 37 additions and 188 deletions

View file

@ -1,14 +1,10 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddHideNotificationsToMute < ActiveRecord::Migration[5.1]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
add_column_with_default :mutes, :hide_notifications, :boolean, default: true, allow_null: false
add_column :mutes, :hide_notifications, :boolean, default: true, null: false
end
def down

View file

@ -1,14 +1,10 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddDisabledToCustomEmojis < ActiveRecord::Migration[5.2]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured { add_column_with_default :custom_emojis, :disabled, :bool, default: false }
safety_assured { add_column :custom_emojis, :disabled, :bool, default: false, null: false }
end
def down

View file

@ -1,16 +1,12 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddReblogsToFollows < ActiveRecord::Migration[5.2]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured do
add_column_with_default :follows, :show_reblogs, :boolean, default: true, allow_null: false
add_column_with_default :follow_requests, :show_reblogs, :boolean, default: true, allow_null: false
add_column :follows, :show_reblogs, :boolean, default: true, null: false
add_column :follow_requests, :show_reblogs, :boolean, default: true, null: false
end
end

View file

@ -1,14 +1,10 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddMemorialToAccounts < ActiveRecord::Migration[5.2]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured { add_column_with_default :accounts, :memorial, :bool, default: false }
safety_assured { add_column :accounts, :memorial, :bool, default: false, null: false }
end
def down

View file

@ -1,14 +1,10 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddDisabledToUsers < ActiveRecord::Migration[5.2]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured { add_column_with_default :users, :disabled, :bool, default: false }
safety_assured { add_column :users, :disabled, :bool, default: false, null: false }
end
def down

View file

@ -1,14 +1,10 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddModeratorToAccounts < ActiveRecord::Migration[5.2]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured { add_column_with_default :users, :moderator, :bool, default: false }
safety_assured { add_column :users, :moderator, :bool, default: false, null: false }
end
def down

View file

@ -1,15 +1,11 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddEmbedURLToPreviewCards < ActiveRecord::Migration[5.2]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured do
add_column_with_default :preview_cards, :embed_url, :string, default: '', allow_null: false
add_column :preview_cards, :embed_url, :string, default: '', null: false
end
end

View file

@ -1,15 +1,11 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddAutofollowToInvites < ActiveRecord::Migration[5.2]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured do
add_column_with_default :invites, :autofollow, :bool, default: false, allow_null: false
add_column :invites, :autofollow, :bool, default: false, null: false
end
end

View file

@ -1,15 +1,11 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddWholeWordToCustomFilter < ActiveRecord::Migration[5.2]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def change
safety_assured do
add_column_with_default :custom_filters, :whole_word, :boolean, default: true, allow_null: false
add_column :custom_filters, :whole_word, :boolean, default: true, null: false
end
end

View file

@ -1,19 +1,15 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddConfidentialToDoorkeeperApplication < ActiveRecord::Migration[5.2]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured do
add_column_with_default(
add_column(
:oauth_applications,
:confidential,
:boolean,
allow_null: false,
null: false,
default: true # maintaining backwards compatibility: require secrets
)
end

View file

@ -1,19 +1,15 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddSilentToMentions < ActiveRecord::Migration[5.2]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured do
add_column_with_default(
add_column(
:mentions,
:silent,
:boolean,
allow_null: false,
null: false,
default: false
)
end

View file

@ -1,15 +1,11 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddRejectReportsToDomainBlocks < ActiveRecord::Migration[5.2]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured do
add_column_with_default :domain_blocks, :reject_reports, :boolean, default: false, allow_null: false
add_column :domain_blocks, :reject_reports, :boolean, default: false, null: false
end
end

View file

@ -1,19 +1,15 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddUnreadToAccountConversations < ActiveRecord::Migration[5.2]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured do
add_column_with_default(
add_column(
:account_conversations,
:unread,
:boolean,
allow_null: false,
null: false,
default: false
)
end

View file

@ -1,19 +1,15 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddShowRepliesToLists < ActiveRecord::Migration[5.2]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured do
add_column_with_default(
add_column(
:lists,
:replies_policy,
:integer,
allow_null: false,
null: false,
default: 0
)
end

View file

@ -1,15 +1,11 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddOverwriteToImports < ActiveRecord::Migration[5.2]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured do
add_column_with_default :imports, :overwrite, :boolean, default: false, allow_null: false
add_column :imports, :overwrite, :boolean, default: false, null: false
end
end

View file

@ -1,19 +1,15 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddLockVersionToPolls < ActiveRecord::Migration[5.2]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured do
add_column_with_default(
add_column(
:polls,
:lock_version,
:integer,
allow_null: false,
null: false,
default: 0
)
end

View file

@ -1,19 +1,15 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddApprovedToUsers < ActiveRecord::Migration[5.2]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured do
add_column_with_default(
add_column(
:users,
:approved,
:bool,
allow_null: false,
null: false,
default: true
)
end

View file

@ -1,14 +1,10 @@
# frozen_string_literal: true
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 }
safety_assured { add_column :account_stats, :lock_version, :integer, null: false, default: 0 }
end
def down

View file

@ -1,14 +1,10 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddTitleToAccountWarningPresets < ActiveRecord::Migration[5.2]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured { add_column_with_default :account_warning_presets, :title, :string, default: '', allow_null: false }
safety_assured { add_column :account_warning_presets, :title, :string, default: '', null: false }
end
def down

View file

@ -1,16 +1,12 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddNotifyToFollows < ActiveRecord::Migration[5.2]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured do
add_column_with_default :follows, :notify, :boolean, default: false, allow_null: false
add_column_with_default :follow_requests, :notify, :boolean, default: false, allow_null: false
add_column :follows, :notify, :boolean, default: false, null: false
add_column :follow_requests, :notify, :boolean, default: false, null: false
end
end

View file

@ -1,14 +1,10 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddObfuscateToDomainBlocks < ActiveRecord::Migration[5.2]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured { add_column_with_default :domain_blocks, :obfuscate, :boolean, default: false, allow_null: false }
safety_assured { add_column :domain_blocks, :obfuscate, :boolean, default: false, null: false }
end
def down

View file

@ -1,15 +1,11 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddCategoryToReports < ActiveRecord::Migration[6.1]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured do
add_column_with_default :reports, :category, :int, default: 0, allow_null: false
add_column :reports, :category, :int, default: 0, null: false
change_table(:reports, bulk: true) do |t|
t.column :action_taken_at, :datetime
t.column :rule_ids, :bigint, array: true

View file

@ -1,15 +1,11 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddActionToCustomFilters < ActiveRecord::Migration[6.1]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured do
add_column_with_default :custom_filters, :action, :integer, allow_null: false, default: 0
add_column :custom_filters, :action, :integer, null: false, default: 0
execute 'UPDATE custom_filters SET action = 1 WHERE irreversible IS TRUE'
end
end

View file

@ -1,14 +1,10 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddExclusiveToLists < ActiveRecord::Migration[6.1]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured { add_column_with_default :lists, :exclusive, :boolean, default: false, allow_null: false }
safety_assured { add_column :lists, :exclusive, :boolean, default: false, null: false }
end
def down

View file

@ -1,14 +1,10 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddImageDescriptionToPreviewCards < ActiveRecord::Migration[7.0]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured { add_column_with_default :preview_cards, :image_description, :string, default: '', allow_null: false }
safety_assured { add_column :preview_cards, :image_description, :string, default: '', null: false }
end
def down

View file

@ -1,14 +1,10 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddIndexableToAccounts < ActiveRecord::Migration[7.0]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured { add_column_with_default :accounts, :indexable, :boolean, default: false, allow_null: false }
safety_assured { add_column :accounts, :indexable, :boolean, default: false, null: false }
end
def down

View file

@ -1,10 +1,6 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class RemoveWholeWordFromCustomFilters < ActiveRecord::Migration[6.1]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
@ -15,7 +11,7 @@ class RemoveWholeWordFromCustomFilters < ActiveRecord::Migration[6.1]
def down
safety_assured do
add_column_with_default :custom_filters, :whole_word, :boolean, default: true, allow_null: false
add_column :custom_filters, :whole_word, :boolean, default: true, null: false
end
end
end

View file

@ -1,10 +1,6 @@
# frozen_string_literal: true
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class RemoveIrreversibleFromCustomFilters < ActiveRecord::Migration[6.1]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
@ -15,7 +11,7 @@ class RemoveIrreversibleFromCustomFilters < ActiveRecord::Migration[6.1]
def down
safety_assured do
add_column_with_default :custom_filters, :irreversible, :boolean, allow_null: false, default: false
add_column :custom_filters, :irreversible, :boolean, null: false, default: false
end
end
end