diff --git a/db/migrate/20190201173316_add_missing_ems_id_to_switch.rb b/db/migrate/20190201173316_add_missing_ems_id_to_switch.rb index 648bab4d..a777bdc2 100644 --- a/db/migrate/20190201173316_add_missing_ems_id_to_switch.rb +++ b/db/migrate/20190201173316_add_missing_ems_id_to_switch.rb @@ -1,4 +1,32 @@ class AddMissingEmsIdToSwitch < ActiveRecord::Migration[5.0] + class ExtManagementSystem < ActiveRecord::Base + self.inheritance_column = :_type_disabled + end + + class Host < ActiveRecord::Base + self.inheritance_column = :_type_disabled + + belongs_to :ext_management_system, :foreign_key => "ems_id", :class_name => "AddMissingEmsIdToSwitch::ExtManagementSystem" + + has_many :host_switches, :class_name => "AddMissingEmsIdToSwitch::HostSwitch" + has_many :switches, :through => :host_switches, :class_name => "AddMissingEmsIdToSwitch::Switch" + end + + class HostSwitch < ActiveRecord::Base + belongs_to :host, :class_name => "AddMissingEmsIdToSwitch::Host" + belongs_to :switch, :class_name => "AddMissingEmsIdToSwitch::Switch" + end + + class Switch < ActiveRecord::Base + self.inheritance_column = :_type_disabled + + belongs_to :ext_management_system, :foreign_key => "ems_id", :class_name => "AddMissingEmsIdToSwitch::ExtManagementSystem" + belongs_to :host, :class_name => "AddMissingEmsIdToSwitch::Host" + + has_many :hosts, :through => :host_switches, :class_name => "AddMissingEmsIdToSwitch::Host" + has_many :host_switches, :class_name => "AddMissingEmsIdToSwitch::HostSwitch" + end + def up say_with_time("Add missing ems_id to switch") do connection.execute <<-SQL diff --git a/spec/migrations/20190201173316_add_missing_ems_id_to_switch_spec.rb b/spec/migrations/20190201173316_add_missing_ems_id_to_switch_spec.rb index d6be3a79..281729f5 100644 --- a/spec/migrations/20190201173316_add_missing_ems_id_to_switch_spec.rb +++ b/spec/migrations/20190201173316_add_missing_ems_id_to_switch_spec.rb @@ -1,35 +1,5 @@ require_migration -class AddMissingEmsIdToSwitch < ActiveRecord::Migration[5.0] - class ExtManagementSystem < ActiveRecord::Base - self.inheritance_column = :_type_disabled - end - - class Host < ActiveRecord::Base - self.inheritance_column = :_type_disabled - - belongs_to :ext_management_system, :foreign_key => "ems_id", :class_name => "AddMissingEmsIdToSwitch::ExtManagementSystem" - - has_many :host_switches, :class_name => "AddMissingEmsIdToSwitch::HostSwitch" - has_many :switches, :through => :host_switches, :class_name => "AddMissingEmsIdToSwitch::Switch" - end - - class HostSwitch < ActiveRecord::Base - belongs_to :host, :class_name => "AddMissingEmsIdToSwitch::Host" - belongs_to :switch, :class_name => "AddMissingEmsIdToSwitch::Switch" - end - - class Switch < ActiveRecord::Base - self.inheritance_column = :_type_disabled - - belongs_to :ext_management_system, :foreign_key => "ems_id", :class_name => "AddMissingEmsIdToSwitch::ExtManagementSystem" - belongs_to :host, :class_name => "AddMissingEmsIdToSwitch::Host" - - has_many :hosts, :through => :host_switches, :class_name => "AddMissingEmsIdToSwitch::Host" - has_many :host_switches, :class_name => "AddMissingEmsIdToSwitch::HostSwitch" - end -end - describe AddMissingEmsIdToSwitch do let(:switch_stub) { migration_stub(:Switch) } let(:host_stub) { migration_stub(:Host) }