Move db engine changing into db adaptor monkeypatch

This commit is contained in:
Andy Allan 2008-11-08 18:04:36 +00:00
parent c19d1b406b
commit 91374368fa
4 changed files with 12 additions and 4 deletions

View file

@ -29,7 +29,7 @@ class CleanupOsmDb < ActiveRecord::Migration
change_column "current_ways", "user_id", :bigint, :limit => 20, :null => false
change_column "current_ways", "timestamp", :datetime, :null => false
change_column "current_ways", "visible", :boolean, :null => false
execute "ALTER TABLE current_ways ENGINE = InnoDB"
change_engine "current_ways", "InnoDB"
change_column "diary_entries", "title", :string, :null => false
change_column "diary_entries", "body", :text, :null => false
@ -191,7 +191,7 @@ class CleanupOsmDb < ActiveRecord::Migration
change_column "diary_entries", "body", :text
change_column "diary_entries", "title", :string, :default => nil
execute "ALTER TABLE current_ways ENGINE = MyISAM"
change_engine "current_ways", "MyISAM"
change_column "current_ways", "visible", :boolean
change_column "current_ways", "timestamp", :datetime
change_column "current_ways", "user_id", :bigint, :limit => 20

View file

@ -1,6 +1,6 @@
class SqlSessionStoreSetup < ActiveRecord::Migration
def self.up
create_table "sessions", :options => "ENGINE=InnoDB" do |t|
create_table "sessions", :options => innodb_option do |t|
t.column "session_id", :string
t.column "data", :text
t.column "created_at", :timestamp

View file

@ -14,7 +14,7 @@ class MoveToInnodb < ActiveRecord::Migration
}
@@conv_tables.each { |tbl|
execute "ALTER TABLE #{tbl} ENGINE = InnoDB"
change_engine (tbl, "InnoDB")
}
@@ver_tbl.each { |tbl|

View file

@ -73,6 +73,14 @@ module ActiveRecord
def innodb_table
return { :id => false, :force => true, :options => "ENGINE=InnoDB" }
end
def innodb_option
return "ENGINE=InnoDB"
end
def change_engine (table_name, engine)
execute "ALTER TABLE #{table_name} ENGINE = #{engine}"
end
end
end
end