Skip to content

Commit

Permalink
Disable STI on AR subclasses used for migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
bdunne committed Aug 8, 2018
1 parent 087e18f commit efafe43
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class Configuration < ActiveRecord::Base
serialize :settings, Hash
end

class FileDepot < ActiveRecord::Base; end
class FileDepot < ActiveRecord::Base
self.inheritance_column = :_type_disabled
end

class MiqServer < ActiveRecord::Base; end

Expand Down
4 changes: 3 additions & 1 deletion db/migrate/20150907095639_add_container_image_digest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ class AddContainerImageDigest < ActiveRecord::Migration[4.2]
# https://github.com/docker/distribution/blob/v2.1.1/digest/digester.go#L15-L17
SUPPORTED_DIGESTS = 'sha256', 'sha384', 'sha512'

class ContainerImage < ActiveRecord::Base; end
class ContainerImage < ActiveRecord::Base
self.inheritance_column = :_type_disabled
end

def up
add_column :container_images, :digest, :string
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20160322195653_move_switch_host_to_jointable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Host < ActiveRecord::Base
end

class Switch < ActiveRecord::Base
self.inheritance_column = :_type_disabled
belongs_to :host, :class_name => 'MoveSwitchHostToJointable::Host'
end

Expand Down
1 change: 1 addition & 0 deletions db/migrate/20160322205357_remove_host_id_from_switch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Host < ActiveRecord::Base
end

class Switch < ActiveRecord::Base
self.inheritance_column = :_type_disabled
has_many :host_switches, :dependent => :destroy, :class_name => 'RemoveHostIdFromSwitch::HostSwitch'
has_many :hosts, :through => :host_switches, :class_name => 'RemoveHostIdFromSwitch::Host'
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ class MiqWorker < ActiveRecord::Base
self.inheritance_column = :_type_disabled
end

class Authentication < ActiveRecord::Base; end
class Authentication < ActiveRecord::Base
self.inheritance_column = :_type_disabled
end

class MiqQueue < ActiveRecord::Base; end

def up
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class RemoveCentralAdminRegionAuthRecords < ActiveRecord::Migration[5.0]
class Authentication < ActiveRecord::Base; end
class Authentication < ActiveRecord::Base
self.inheritance_column = :_type_disabled
end

def up
Authentication.where(:resource_type => 'MiqRegion').delete_all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ class MiqWorker < ActiveRecord::Base
self.inheritance_column = :_type_disabled
end

class Authentication < ActiveRecord::Base; end
class Authentication < ActiveRecord::Base
self.inheritance_column = :_type_disabled
end

class MiqQueue < ActiveRecord::Base; end

def up
Expand Down
4 changes: 3 additions & 1 deletion db/migrate/20170222214902_add_initiator_to_service.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class AddInitiatorToService < ActiveRecord::Migration[5.0]
class Service < ActiveRecord::Base; end
class Service < ActiveRecord::Base
self.inheritance_column = :_type_disabled
end

def up
add_column :services, :initiator, :string, :comment => "Entity that initiated the service creation"
Expand Down
4 changes: 3 additions & 1 deletion db/migrate/20170409083720_add_enabled_field_to_ems.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class AddEnabledFieldToEms < ActiveRecord::Migration[5.0]
class ExtManagementSystem < ActiveRecord::Base; end
class ExtManagementSystem < ActiveRecord::Base
self.inheritance_column = :_type_disabled
end

def change
add_column :ext_management_systems, :enabled, :boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class ContainerGroup < ActiveRecord::Base
end

class ContainerImage < ActiveRecord::Base
self.inheritance_column = :_type_disabled
end

class ContainerProject < ActiveRecord::Base
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class ContainerDefinition < ActiveRecord::Base
end

class Container < ActiveRecord::Base
self.inheritance_column = :_type_disabled
belongs_to :container_definition, :class_name => 'UnifyContainerDefinitionAndContainer::ContainerDefinition'
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class DowncaseResourceGroupEmsRefForAzure < ActiveRecord::Migration[5.0]
class ResourceGroup < ActiveRecord::Base; end
class ResourceGroup < ActiveRecord::Base
self.inheritance_column = :_type_disabled
end

def up
say_with_time("Downcase ems_ref for Azure resource groups") do
Expand Down

0 comments on commit efafe43

Please sign in to comment.