mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Refactor settings
This commit is contained in:
parent
26f5eda636
commit
dafcb6f78c
25 changed files with 132 additions and 282 deletions
|
@ -1,9 +0,0 @@
|
|||
class CreateSettings < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :settings do |t|
|
||||
t.integer :setting_group_id
|
||||
t.string :code
|
||||
t.string :value
|
||||
end
|
||||
end
|
||||
end
|
18
db/migrate/20141015135255_create_settings.rb
Normal file
18
db/migrate/20141015135255_create_settings.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
class CreateSettings < ActiveRecord::Migration
|
||||
def self.up
|
||||
drop_table :settings
|
||||
create_table :settings do |t|
|
||||
t.string :var, :null => false
|
||||
t.text :value, :null => true
|
||||
t.integer :thing_id, :null => true
|
||||
t.string :thing_type, :limit => 30, :null => true
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :settings, [ :thing_type, :thing_id, :var ], :unique => true
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :settings
|
||||
end
|
||||
end
|
17
db/migrate/20141015135742_correct_settings.rb
Normal file
17
db/migrate/20141015135742_correct_settings.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
class CorrectSettings < ActiveRecord::Migration
|
||||
def up
|
||||
drop_table :setting_groups
|
||||
|
||||
Setting.ds_algorithm = 2
|
||||
Setting.ds_data_allowed = true
|
||||
Setting.ds_data_with_key_allowed = true
|
||||
Setting.key_data_allowed = true
|
||||
|
||||
Setting.dnskeys_min_count = 0
|
||||
Setting.dnskeys_max_count = 9
|
||||
Setting.ns_min_count = 2
|
||||
Setting.ns_max_count = 11
|
||||
|
||||
Setting.transfer_wait_time = 0
|
||||
end
|
||||
end
|
17
db/schema.rb
17
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20141014073435) do
|
||||
ActiveRecord::Schema.define(version: 20141015135742) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -252,15 +252,16 @@ ActiveRecord::Schema.define(version: 20141014073435) do
|
|||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "setting_groups", force: true do |t|
|
||||
t.string "code"
|
||||
create_table "settings", force: true do |t|
|
||||
t.string "var", null: false
|
||||
t.text "value"
|
||||
t.integer "thing_id"
|
||||
t.string "thing_type", limit: 30
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "settings", force: true do |t|
|
||||
t.integer "setting_group_id"
|
||||
t.string "code"
|
||||
t.string "value"
|
||||
end
|
||||
add_index "settings", ["thing_type", "thing_id", "var"], name: "index_settings_on_thing_type_and_thing_id_and_var", unique: true, using: :btree
|
||||
|
||||
create_table "users", force: true do |t|
|
||||
t.string "username"
|
||||
|
|
31
db/seeds.rb
31
db/seeds.rb
|
@ -66,27 +66,16 @@ User.where(
|
|||
country: Country.where(name: 'Estonia').first
|
||||
).first_or_create
|
||||
|
||||
sg = SettingGroup.where(code: 'domain_validation').first_or_create
|
||||
Setting.destroy_all
|
||||
|
||||
s_1 = Setting.where(code: 'ns_min_count').first_or_create
|
||||
s_1.value = 1
|
||||
Setting.create(code: Setting::DS_ALGORITHM, value: 2)
|
||||
Setting.create(code: Setting::ALLOW_DS_DATA, value: 1)
|
||||
Setting.create(code: Setting::ALLOW_DS_DATA_WITH_KEY, value: 1)
|
||||
Setting.create(code: Setting::ALLOW_KEY_DATA, value: 1)
|
||||
|
||||
s_2 = Setting.where(code: 'ns_max_count').first_or_create
|
||||
s_2.value = 13
|
||||
Setting.create(code: Setting::DNSKEYS_MIN_COUNT, value: 9)
|
||||
Setting.create(code: Setting::DNSKEYS_MAX_COUNT, value: 0)
|
||||
Setting.create(code: Setting::NS_MIN_COUNT, value: 2)
|
||||
Setting.create(code: Setting::NS_MAX_COUNT, value: 11)
|
||||
|
||||
s_3 = Setting.where(code: 'dnskeys_min_count').first_or_create
|
||||
s_3.value = 0
|
||||
|
||||
s_4 = Setting.where(code: 'dnskeys_max_count').first_or_create
|
||||
s_4.value = 9
|
||||
|
||||
sg.settings = [s_1, s_2, s_3, s_4]
|
||||
sg.save
|
||||
|
||||
sg = SettingGroup.where(code: 'domain_general').first_or_create
|
||||
|
||||
s_1 = Setting.where(code: 'transfer_wait_time').first_or_create
|
||||
s_1.value = 0
|
||||
|
||||
sg.settings = [s_1]
|
||||
sg.save
|
||||
Setting.create(code: Setting::TRANSFER_WAIT_TIME, value: 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue