Class: ChangeColumns

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

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/20090921165547_change_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, :primary => true)
    end
  when Symbol
    change_column(t, e[1], :integer, :primary => true)
  end
end

.bla_up(e) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/six-updater-web/db/migrate/20090921165547_change_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, :primary => true)
    end
  when Symbol
    change_column(t, e[1], :string, :limit => 36, :null => false, :primary => true)
  end
end

.downObject



14
15
16
17
18
19
20
21
# File 'lib/six-updater-web/db/migrate/20090921165547_change_columns.rb', line 14

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

.upObject



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/six-updater-web/db/migrate/20090921165547_change_columns.rb', line 2

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