Skip to content

Commit

Permalink
Move ConfigurationScriptSource#authentication to GitRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
Fryguy committed Jul 23, 2019
1 parent 42716f8 commit a09a688
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddAuthenticationIdToGitRepository < ActiveRecord::Migration[5.1]
def change
add_column :git_repositories, :authentication_id, :bigint
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class MoveConfigurationScriptSourceAuthenticationToGitRepository < ActiveRecord::Migration[5.1]
class Authentication < ActiveRecord::Base
self.inheritance_column = :_type_disabled
end

class GitRepository < ActiveRecord::Base
belongs_to :authentication, :class_name => parent::Authentication.name
end

class ConfigurationScriptSource < ActiveRecord::Base
self.inheritance_column = :_type_disabled

belongs_to :authentication, :class_name => parent::Authentication.name
belongs_to :git_repository, :class_name => parent::GitRepository.name
end

def up
say_with_time("Moving embedded ansible configuration_script_source authentication to git_repository") do
ConfigurationScriptSource.where(:type => "ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScriptSource").each do |css|
unless css.git_repository
css.update!(:git_repository => GitRepository.create!(:url => scm_url))
end

if css.authentication
css.git_repository.update!(:authentication => css.authentication)
css.update!(:authentication_id => nil) # TODO: Do we need this?
end
end
end
end
end

0 comments on commit a09a688

Please sign in to comment.