openstreetmap-website/db/migrate/013_add_email_valid.rb
Andy Allan d130db9fa8 Avoid more models in old migrations
Although these migrations run fine today, they could break in the future
if changes are made to the current model code.
2019-07-17 12:16:20 +02:00

13 lines
450 B
Ruby

class AddEmailValid < ActiveRecord::Migration[4.2]
class User < ActiveRecord::Base
end
def self.up
add_column "users", "email_valid", :boolean, :default => false, :null => false
User.update_all("email_valid = (active != 0)") # email_valid is :boolean, but active is :integer. "email_valid = active" (see r11802 or earlier) will fail for stricter dbs than mysql
end
def self.down
remove_column "users", "email_valid"
end
end