* Change: #591 ホワイトリストのドメイン一覧の保存先・画面変更 * Update account_batch.rb * 表示まわりを改善 * Update dangerous.rake
This commit is contained in:
parent
8c399cefce
commit
ff2860d0df
18 changed files with 211 additions and 49 deletions
41
db/migrate/20240401222541_create_specified_domains.rb
Normal file
41
db/migrate/20240401222541_create_specified_domains.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateSpecifiedDomains < ActiveRecord::Migration[7.1]
|
||||
class Setting < ApplicationRecord
|
||||
def value
|
||||
YAML.safe_load(self[:value], permitted_classes: [ActiveSupport::HashWithIndifferentAccess, Symbol]) if self[:value].present?
|
||||
end
|
||||
|
||||
def value=(new_value)
|
||||
self[:value] = new_value.to_yaml
|
||||
end
|
||||
end
|
||||
|
||||
class SpecifiedDomain < ApplicationRecord; end
|
||||
|
||||
def up
|
||||
create_table :specified_domains do |t|
|
||||
t.string :domain, null: false
|
||||
t.integer :table, default: 0, null: false
|
||||
t.jsonb :options, null: false, default: {}
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :specified_domains, %i(domain table), unique: true
|
||||
|
||||
setting = Setting.find_by(var: :permit_new_account_domains)
|
||||
|
||||
(setting&.value || []).compact.uniq.each do |domain|
|
||||
SpecifiedDomain.create!(domain: domain, table: 0)
|
||||
end
|
||||
setting&.destroy
|
||||
end
|
||||
|
||||
def down
|
||||
Setting.find_by(var: :permit_new_account_domains)&.destroy
|
||||
Setting.new(var: :permit_new_account_domains).tap { |s| s.value = SpecifiedDomain.where(table: 0).pluck(:domain) }.save!
|
||||
|
||||
drop_table :specified_domains
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue