]> git.openstreetmap.org Git - rails.git/commitdiff
Move db engine changing into db adaptor monkeypatch
authorAndy Allan <gravitystorm@gmail.com>
Sat, 8 Nov 2008 18:04:36 +0000 (18:04 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Sat, 8 Nov 2008 18:04:36 +0000 (18:04 +0000)
db/migrate/002_cleanup_osm_db.rb
db/migrate/003_sql_session_store_setup.rb
db/migrate/019_move_to_innodb.rb
lib/migrate.rb

index 1358febd8c31bfa6c689108d3960eca28f44be38..f283602acad081f56d50c9e8bffafc419f43ad52 100644 (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
index 7b1c75479ac0144798004ddae61f010478aa96a9..4de0dd4b19120e6613528918ea7d96c248e57751 100644 (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
index d17da8fd549649eafdb09e019d779ca986643967..2e9f4adaa68dcd3e72ea49f287289bb87b432124 100644 (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|
index 77bc93646d0eef922d958973e4acd8481df69c79..df7e5f7aee91d08d3aaf345ca27d0dd6bdfd7393 100644 (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