parent
927e02e051
commit
7742f440fa
2 changed files with 19 additions and 9 deletions
|
@ -13,12 +13,17 @@ class AddMasterSettingsToAccounts < ActiveRecord::Migration[7.1]
|
||||||
safety_assured do
|
safety_assured do
|
||||||
add_column :accounts, :master_settings, :jsonb
|
add_column :accounts, :master_settings, :jsonb
|
||||||
|
|
||||||
Account.transaction do
|
if Rails.env.test?
|
||||||
Account.find_in_batches do |accounts|
|
Account.transaction do
|
||||||
accounts.each do |account|
|
Account.find_in_batches do |accounts|
|
||||||
account.update(master_settings: { 'subscription_policy' => account.dissubscribable ? 'block' : 'allow' })
|
accounts.each do |account|
|
||||||
|
account.update(master_settings: { 'subscription_policy' => account.dissubscribable ? 'block' : 'allow' })
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
Account.where(dissubscribable: true).update_all(master_settings: { 'subscription_policy' => 'block' }) # rubocop:disable Rails/SkipsModelValidations
|
||||||
|
Account.where(dissubscribable: false).update_all(master_settings: { 'subscription_policy' => 'allow' }) # rubocop:disable Rails/SkipsModelValidations
|
||||||
end
|
end
|
||||||
|
|
||||||
remove_column :accounts, :dissubscribable
|
remove_column :accounts, :dissubscribable
|
||||||
|
@ -29,12 +34,17 @@ class AddMasterSettingsToAccounts < ActiveRecord::Migration[7.1]
|
||||||
safety_assured do
|
safety_assured do
|
||||||
add_column_with_default :accounts, :dissubscribable, :boolean, default: false, allow_null: false
|
add_column_with_default :accounts, :dissubscribable, :boolean, default: false, allow_null: false
|
||||||
|
|
||||||
Account.transaction do
|
if Rails.env.test?
|
||||||
Account.find_in_batches do |accounts|
|
Account.transaction do
|
||||||
accounts.each do |account|
|
Account.find_in_batches do |accounts|
|
||||||
account.update(dissubscribable: account.master_settings.present? && account.master_settings['subscription_policy'] != 'allow')
|
accounts.each do |account|
|
||||||
|
account.update(dissubscribable: account.master_settings.present? && account.master_settings['subscription_policy'] != 'allow')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
Account.where(master_settings: { subscription_policy: 'block' }).update_all(dissubscribable: true) # rubocop:disable Rails/SkipsModelValidations
|
||||||
|
Account.where(master_settings: { subscription_policy: 'allow' }).update_all(dissubscribable: false) # rubocop:disable Rails/SkipsModelValidations
|
||||||
end
|
end
|
||||||
|
|
||||||
remove_column :accounts, :master_settings
|
remove_column :accounts, :master_settings
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Mastodon
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
def kmyblue_major
|
def kmyblue_major
|
||||||
8
|
9
|
||||||
end
|
end
|
||||||
|
|
||||||
def kmyblue_minor
|
def kmyblue_minor
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue