]> git.openstreetmap.org Git - rails.git/commitdiff
Boolean correctness in migrations
authorAndy Allan <gravitystorm@gmail.com>
Sat, 8 Nov 2008 15:01:14 +0000 (15:01 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Sat, 8 Nov 2008 15:01:14 +0000 (15:01 +0000)
db/migrate/013_add_email_valid.rb
db/migrate/015_add_user_visible.rb
db/migrate/021_add_changesets.rb

index b8af4bf6ad5e7b6c519ba19c2b0f1228d95cd227..2192383bda2e73a65c54dddb9e20e37f40d853a3 100644 (file)
@@ -1,7 +1,7 @@
 class AddEmailValid < ActiveRecord::Migration
   def self.up
     add_column "users", "email_valid", :boolean, :default => false, :null => false
-    User.update_all("email_valid = active")
+    User.update_all(:email_valid => true)
   end
 
   def self.down
index d870dfffdae477c646136afc48a9650bbd2f3eab..869f24c3755c12eb792259d8d53e45594f2371dc 100644 (file)
@@ -1,7 +1,7 @@
 class AddUserVisible < ActiveRecord::Migration
   def self.up
     add_column "users", "visible", :boolean, :default => true, :null => false
-    User.update_all("visible = 1")
+    User.update_all(:visible => true)
   end
 
   def self.down
index 9b769c772a0ce2790e25f774ec8ca3c6b6400f54..e0cf3904a50d8ea98f79e40d1e20f5f8707336ae 100644 (file)
@@ -28,7 +28,7 @@ class AddChangesets < ActiveRecord::Migration
     # all the changesets will have the id of the user that made them.
     # We need to generate a changeset for each user in the database
     execute "INSERT INTO changesets (id, user_id, created_at, open)" + 
-      "SELECT id, id, creation_time, 0 from users;"
+      "SELECT id, id, creation_time, false from users;"
 
     @@conv_user_tables.each { |tbl|
       rename_column tbl, :user_id, :changeset_id