1 class MoveToInnodb < ActiveRecord::Migration
2 @@conv_tables = ['nodes', 'ways', 'way_tags', 'way_nodes',
3 'current_way_nodes', 'current_way_tags', 'relation_members',
4 'relations', 'relation_tags', 'current_relation_tags']
6 @@ver_tbl = ['nodes', 'ways', 'relations']
9 execute 'DROP INDEX current_way_tags_v_idx ON current_way_tags'
10 execute 'DROP INDEX current_relation_tags_v_idx ON current_relation_tags'
12 @@ver_tbl.each { |tbl|
13 change_column tbl, "version", :bigint, :limit => 20, :null => false
16 @@conv_tables.each { |tbl|
17 execute "ALTER TABLE #{tbl} ENGINE = InnoDB"
20 @@ver_tbl.each { |tbl|
21 add_column "current_#{tbl}", "version", :bigint, :limit => 20, :null => false
22 execute "UPDATE current_#{tbl} SET version = " +
23 "(SELECT max(version)+1 FROM #{tbl} WHERE #{tbl}.id = current_#{tbl}.id)"
28 raise IrreversibleMigration.new