Change: #591 ホワイトリストのドメイン一覧の保存先・画面変更 (#689)

* Change: #591 ホワイトリストのドメイン一覧の保存先・画面変更

* Update account_batch.rb

* 表示まわりを改善

* Update dangerous.rake
This commit is contained in:
KMY(雪あすか) 2024-04-03 12:09:43 +09:00 committed by GitHub
parent 8c399cefce
commit ff2860d0df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 211 additions and 49 deletions

View 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

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2024_03_27_234026) do
ActiveRecord::Schema[7.1].define(version: 2024_04_01_222541) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -1328,6 +1328,15 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_27_234026) do
t.index ["version"], name: "index_software_updates_on_version", unique: true
end
create_table "specified_domains", force: :cascade do |t|
t.string "domain", null: false
t.integer "table", default: 0, null: false
t.jsonb "options", default: {}, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["domain", "table"], name: "index_specified_domains_on_domain_and_table", unique: true
end
create_table "status_capability_tokens", force: :cascade do |t|
t.bigint "status_id", null: false
t.string "token"