Class: Change2Columns

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/six-updater-web/db/migrate/20090928163561_change2_columns.rb

Constant Summary collapse

CHANGE =
[[:mods_sixconfigs, [:sixconfig_id, :mod_id]]]
TABLES =
[:sixconfigs, :appsettings, :actions]

Class Method Summary collapse

Class Method Details

.bla_down(e) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/six-updater-web/db/migrate/20090928163561_change2_columns.rb', line 35

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

.bla_up(e) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/six-updater-web/db/migrate/20090928163561_change2_columns.rb', line 23

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

.downObject



18
19
20
21
# File 'lib/six-updater-web/db/migrate/20090928163561_change2_columns.rb', line 18

def self.down
  TABLES.each { |t| change_column(t, :id, :integer) }
  CHANGE.each { |e| bla_down(e) }
end

.upObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/six-updater-web/db/migrate/20090928163561_change2_columns.rb', line 5

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