Sha256: ca15fd03fdfbda55f15f2a5af9c8e55c637813cbe2028eb868b59fd0f612a2e8

Contents?: true

Size: 994 Bytes

Versions: 12

Compression:

Stored size: 994 Bytes

Contents

class PopulateUpstreamAuthenticationToken < ActiveRecord::Migration[6.0]
  def up
    return unless ActiveRecord::Base.connection.column_exists?('katello_root_repositories', 'upstream_authentication_token')

    scc_repositories = SccRepository.includes(:scc_katello_repositories).where.not(scc_katello_repositories: { id: nil })
    scc_repositories.each do |scc_repo|
      scc_repo.katello_root_repositories.each do |katello_repo|
        katello_repo.update!(url: scc_repo.url, upstream_authentication_token: scc_repo.token)
      end
    end
  end

  def down
    return if ActiveRecord::Base.connection.column_exists?('katello_root_repositories', 'upstream_authentication_token')

    scc_repositories = SccRepository.includes(:scc_katello_repositories).where.not(scc_katello_repositories: { id: nil })
    scc_repositories.each do |scc_repo|
      scc_repo.katello_root_repositories.each do |katello_repo|
        katello_repo.update!(url: scc_repo.full_url)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
foreman_scc_manager-4.0.0 db/migrate/20220513132652_populate_upstream_authentication_token.rb
foreman_scc_manager-3.1.1 db/migrate/20220513132652_populate_upstream_authentication_token.rb
foreman_scc_manager-3.1.0 db/migrate/20220513132652_populate_upstream_authentication_token.rb
foreman_scc_manager-3.0.0 db/migrate/20220513132652_populate_upstream_authentication_token.rb
foreman_scc_manager-2.3.0 db/migrate/20220513132652_populate_upstream_authentication_token.rb
foreman_scc_manager-2.2.3 db/migrate/20220513132652_populate_upstream_authentication_token.rb
foreman_scc_manager-2.2.2 db/migrate/20220513132652_populate_upstream_authentication_token.rb
foreman_scc_manager-2.2.1 db/migrate/20220513132652_populate_upstream_authentication_token.rb
foreman_scc_manager-2.2.0 db/migrate/20220513132652_populate_upstream_authentication_token.rb
foreman_scc_manager-2.1.0 db/migrate/20220513132652_populate_upstream_authentication_token.rb
foreman_scc_manager-2.0.0 db/migrate/20220513132652_populate_upstream_authentication_token.rb
foreman_scc_manager-1.8.20 db/migrate/20220513132652_populate_upstream_authentication_token.rb