Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Move ConfigurationScriptSource#authentication to GitRepository #394

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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