mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 18:29:40 +02:00
Attach nameservers directly to domain
This commit is contained in:
parent
98c2717539
commit
eb8de6479e
8 changed files with 22 additions and 36 deletions
|
@ -1,5 +1,4 @@
|
|||
class Admin::NameserversController < ApplicationController
|
||||
# TODO: Refactor this to domain_nameservers controller!
|
||||
before_action :set_domain
|
||||
before_action :set_nameserver, only: [:edit, :update, :destroy]
|
||||
|
||||
|
|
|
@ -14,8 +14,7 @@ class Domain < ActiveRecord::Base
|
|||
where(domain_contacts: { contact_type: DomainContact::ADMIN })
|
||||
end, through: :domain_contacts, source: :contact
|
||||
|
||||
has_many :domain_nameservers, dependent: :delete_all
|
||||
has_many :nameservers, through: :domain_nameservers
|
||||
has_many :nameservers, dependent: :delete_all
|
||||
|
||||
has_many :domain_statuses, dependent: :delete_all
|
||||
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
class DomainNameserver < ActiveRecord::Base
|
||||
belongs_to :domain
|
||||
belongs_to :nameserver
|
||||
end
|
|
@ -6,9 +6,7 @@ class Nameserver < ActiveRecord::Base
|
|||
}
|
||||
|
||||
belongs_to :registrar
|
||||
|
||||
has_many :domain_nameservers, dependent: :delete_all
|
||||
has_many :domains, through: :domain_nameservers
|
||||
belongs_to :domain
|
||||
|
||||
validates :hostname, format: { with: /\A(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\z/ }
|
||||
validates :ipv4, format: { with: /\A(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\z/, allow_blank: true }
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
class AddDomainDirectlyToNameserver < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :nameservers, :domain_id, :integer
|
||||
remove_column :nameservers, :ns_set_id
|
||||
drop_table :nameservers_ns_sets
|
||||
drop_table :ns_sets
|
||||
end
|
||||
end
|
8
db/migrate/20140911101604_clean_redundant_fields.rb
Normal file
8
db/migrate/20140911101604_clean_redundant_fields.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
class CleanRedundantFields < ActiveRecord::Migration
|
||||
def change
|
||||
drop_table :domain_nameservers
|
||||
remove_column :domains, :admin_contact_id
|
||||
remove_column :domains, :technical_contact_id
|
||||
remove_column :domains, :ns_set_id
|
||||
end
|
||||
end
|
26
db/schema.rb
26
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: 20140902121843) do
|
||||
ActiveRecord::Schema.define(version: 20140911101604) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -77,11 +77,6 @@ ActiveRecord::Schema.define(version: 20140902121843) do
|
|||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "domain_nameservers", id: false, force: true do |t|
|
||||
t.integer "domain_id"
|
||||
t.integer "nameserver_id"
|
||||
end
|
||||
|
||||
create_table "domain_statuses", force: true do |t|
|
||||
t.integer "domain_id"
|
||||
t.string "description"
|
||||
|
@ -107,9 +102,6 @@ ActiveRecord::Schema.define(version: 20140902121843) do
|
|||
t.datetime "valid_from"
|
||||
t.datetime "valid_to"
|
||||
t.integer "owner_contact_id"
|
||||
t.integer "admin_contact_id"
|
||||
t.integer "technical_contact_id"
|
||||
t.integer "ns_set_id"
|
||||
t.string "auth_info"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
|
@ -143,24 +135,10 @@ ActiveRecord::Schema.define(version: 20140902121843) do
|
|||
create_table "nameservers", force: true do |t|
|
||||
t.string "hostname"
|
||||
t.string "ipv4"
|
||||
t.integer "ns_set_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "ipv6"
|
||||
end
|
||||
|
||||
create_table "nameservers_ns_sets", force: true do |t|
|
||||
t.integer "nameserver_id"
|
||||
t.integer "ns_set_id"
|
||||
end
|
||||
|
||||
create_table "ns_sets", force: true do |t|
|
||||
t.string "code"
|
||||
t.integer "registrar_id"
|
||||
t.string "auth_info"
|
||||
t.string "report_level"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.integer "domain_id"
|
||||
end
|
||||
|
||||
create_table "registrars", force: true do |t|
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Nameserver do
|
||||
it { should have_and_belong_to_many(:domains) }
|
||||
it { should belong_to(:domain) }
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue