Sha256: 1ce63b74fdc9f2e2fb82b6f06da233dac97e00023ca34edf1cf2051fae6265d2

Contents?: true

Size: 1011 Bytes

Versions: 5

Compression:

Stored size: 1011 Bytes

Contents

class CorrectMedia < ActiveRecord::Migration
  def self.up
    if table_exists? :medias
      if table_exists? :medias_operatingsystems
        rename_column :medias_operatingsystems, :media_id, :medium_id
        rename_table :medias_operatingsystems, :media_operatingsystems
      end

      change_table :hosts do |t|
        t.remove_index :name => :host_media_id_ix
        t.rename :media_id, :medium_id
        t.index :medium_id, :name => :host_medium_id_ix
      end

      rename_table :medias, :media
    end
  end

  def self.down
    if table_exists? :media
      if table_exists? :media_operatingsystems
        rename_column :medias_operatingsystems, :medium_id, :media_id
        rename_table :media_operatingsystems, :medias_operatingsystems
      end

      change_table :hosts do |t|
        t.remove_index :name => :host_medium_id_ix
        t.rename :medium_id, :media_id
        t.index :media_id, :name => :host_media_id_ix
      end

      rename_table :media, :medias
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_discovery-1.0.0 test/foreman_app/db/migrate/20101118130026_correct_media.rb
foreman_discovery-1.0.0.rc4 test/foreman_app/db/migrate/20101118130026_correct_media.rb
foreman_discovery-1.0.0.rc3 test/foreman_app/db/migrate/20101118130026_correct_media.rb
foreman_discovery-1.0.0.rc2 test/foreman_app/db/migrate/20101118130026_correct_media.rb
foreman_discovery-1.0.0.rc1 test/foreman_app/db/migrate/20101118130026_correct_media.rb