Project

General

Profile

Download (1.04 KB) Statistics
| Branch: | Tag: | Revision:

foreman_docker / db / migrate / 20160605134652_move_parameters_to_docker_parameters.rb @ fb471374

1
class MoveParametersToDockerParameters < ActiveRecord::Migration[4.2]
2
  class FakeDockerParameter < ApplicationRecord
3
    self.table_name = 'docker_parameters'
4
  end
5

    
6
  class FakeParameter < ApplicationRecord
7
    self.table_name = 'parameters'
8
  end
9

    
10
  def up
11
  # All the  DockerContainerWizardStates::PARAMETER are temporary for the wizard step so no need to keep them
12
   docker_params = FakeParameter.unscoped.where(:type => ['EnvironmentVariable', 'ForemanDocker::Dns', 'ExposedPort'])
13
   docker_params.each do |param|
14
     DockerParameter.create(:key => param['name'], :value => param['value'], :reference_id => param['reference_id'], :type => param['type'])
15
   end
16
   docker_params.delete_all
17
  end
18

    
19
  def down
20
    docker_params = FakeDockerParameter.unscoped.where(:type => ['EnvironmentVariable', 'ForemanDocker::Dns', 'ExposedPort'])
21
    docker_params.each do |param|
22
      Parameter.create(:key => param['name'], :value => param['value'], :reference_id => param['reference_id'], :type => param['type'])
23
    end
24

    
25
    docker_params.delete_all
26
  end
27
end