* Wip: マイグレーション、設定など一式 * Fix test * Fix test * Fix: マスター用の設定を他サーバーに送信しないよう修正 * DTL、外部サーバーの情報受け入れのテストを追加 * スペルミスを修正 * Web画面に設定項目追加 * 既存の`master_settings`を上書きしないよう修正
43 lines
1.1 KiB
Ruby
43 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
|
|
|
class AddMasterSettingsToAccounts < ActiveRecord::Migration[7.1]
|
|
include Mastodon::MigrationHelpers
|
|
|
|
disable_ddl_transaction!
|
|
|
|
class Account < ApplicationRecord; end
|
|
|
|
def up
|
|
safety_assured do
|
|
add_column :accounts, :master_settings, :jsonb
|
|
|
|
Account.transaction do
|
|
Account.find_in_batches do |accounts|
|
|
accounts.each do |account|
|
|
account.update(master_settings: { 'subscription_policy' => account.dissubscribable ? 'block' : 'allow' })
|
|
end
|
|
end
|
|
end
|
|
|
|
remove_column :accounts, :dissubscribable
|
|
end
|
|
end
|
|
|
|
def down
|
|
safety_assured do
|
|
add_column_with_default :accounts, :dissubscribable, :boolean, default: false, allow_null: false
|
|
|
|
Account.transaction do
|
|
Account.find_in_batches do |accounts|
|
|
accounts.each do |account|
|
|
account.update(dissubscribable: account.master_settings.present? && account.master_settings['subscription_policy'] != 'allow')
|
|
end
|
|
end
|
|
end
|
|
|
|
remove_column :accounts, :master_settings
|
|
end
|
|
end
|
|
end
|