Sha256: ae8955987ce610f82c6be654a7db7a6a9b2113710dc076a5c26d405661c73f81

Contents?: true

Size: 1.21 KB

Versions: 96

Compression:

Stored size: 1.21 KB

Contents

class ChangeColumns < ActiveRecord::Migration
  def self.up
    [:mods, :servers, :repositories].each do |t|
      change_column(t, :id, :string, :limit => 36, :null => false, :primary => true)
    end

    [[:mods_servers, [:server_id, :mod_id]], [:mods_sixconfigs, :mod_id], [:servers_sixconfigs, :server_id]].each do |e|
      bla_up(e)
    end
    drop_table :mods_repositories
    drop_table :repositories_servers
  end

  def self.down
    [:mods, :servers, :repositories].each do |t|
      change_column(t, :id, :integer)
    end
    [[:mods_servers, [:server_id, :mod_id]], [:mods_sixconfigs, :mod_id], [:servers_sixconfigs, :server_id]].each do |e|
      bla_down(e)
    end
  end

  def self.bla_up(e)
    t = e[0]
    case e[1]
    when Array
      e[1].each do |f|
        change_column(t, f, :string, :limit => 36, :null => false, :primary => true)
      end
    when Symbol
      change_column(t, e[1], :string, :limit => 36, :null => false, :primary => true)
    end
  end

  def self.bla_down(e)
    t = e[0]
    case e[1]
    when Array
      e[1].each do |f|
        change_column(t, f, :integer, :primary => true)
      end
    when Symbol
      change_column(t, e[1], :integer, :primary => true)
    end
  end
end

Version data entries

96 entries across 96 versions & 1 rubygems

Version Path
six-updater-web-0.20.3 lib/six-updater-web/db/migrate/20090921165547_change_columns.rb
six-updater-web-0.20.2 lib/six-updater-web/db/migrate/20090921165547_change_columns.rb
six-updater-web-0.20.1 lib/six-updater-web/db/migrate/20090921165547_change_columns.rb
six-updater-web-0.20.0 lib/six-updater-web/db/migrate/20090921165547_change_columns.rb
six-updater-web-0.19.7 lib/six-updater-web/db/migrate/20090921165547_change_columns.rb
six-updater-web-0.19.6 lib/six-updater-web/db/migrate/20090921165547_change_columns.rb
six-updater-web-0.19.5 lib/six-updater-web/db/migrate/20090921165547_change_columns.rb
six-updater-web-0.19.4 lib/six-updater-web/db/migrate/20090921165547_change_columns.rb
six-updater-web-0.19.3 lib/six-updater-web/db/migrate/20090921165547_change_columns.rb
six-updater-web-0.19.2 lib/six-updater-web/db/migrate/20090921165547_change_columns.rb
six-updater-web-0.19.1 lib/six-updater-web/db/migrate/20090921165547_change_columns.rb
six-updater-web-0.19.0 lib/six-updater-web/db/migrate/20090921165547_change_columns.rb
six-updater-web-0.18.2 lib/six-updater-web/db/migrate/20090921165547_change_columns.rb
six-updater-web-0.18.1 lib/six-updater-web/db/migrate/20090921165547_change_columns.rb
six-updater-web-0.18.0 lib/six-updater-web/db/migrate/20090921165547_change_columns.rb
six-updater-web-0.17.7 lib/six-updater-web/db/migrate/20090921165547_change_columns.rb
six-updater-web-0.17.6 lib/six-updater-web/db/migrate/20090921165547_change_columns.rb
six-updater-web-0.17.5 lib/six-updater-web/db/migrate/20090921165547_change_columns.rb
six-updater-web-0.17.4 lib/six-updater-web/db/migrate/20090921165547_change_columns.rb
six-updater-web-0.17.3 lib/six-updater-web/db/migrate/20090921165547_change_columns.rb