forked from ManageIQ/manageiq-schema
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move ConfigurationScriptSource#authentication to GitRepository
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
db/migrate/20190723023214_add_authentication_id_to_git_repository.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
31 changes: 31 additions & 0 deletions
31
...grate/20190723023241_move_configuration_script_source_authentication_to_git_repository.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |