* 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
|
11
db/schema.rb
11
db/schema.rb
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue