Sha256: 809ccf27ecec5f031d9fa5460a17e8f9cc19d61a748072487956e57eae378c54
Contents?: true
Size: 1.17 KB
Versions: 96
Compression:
Stored size: 1.17 KB
Contents
class Change2Columns < ActiveRecord::Migration CHANGE = [[:mods_sixconfigs, [:sixconfig_id, :mod_id]]] TABLES = [:sixconfigs, :appsettings, :actions] def self.up TABLES.each { |t| change_column(t, :id, :string, :limit => 36, :null => false, :primary => true) } CHANGE.each { |e| bla_up(e) } drop_table :actions_sixconfigs drop_table :appsettings_sixconfigs drop_table :servers_sixconfigs add_column(:sixconfigs, :appsetting_id, :string, :limit => 36) add_column(:sixconfigs, :server_id, :string, :limit => 36) add_column(:sixconfigs, :action_id, :string, :limit => 36) end def self.down TABLES.each { |t| change_column(t, :id, :integer) } CHANGE.each { |e| bla_down(e) } 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) end when Symbol change_column(t, e[1], :string, :limit => 36, :null => false) 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) end when Symbol change_column(t, e[1], :integer) end end end
Version data entries
96 entries across 96 versions & 1 rubygems