class RenameLicenseAgreementVersionToTosAccepted < ActiveRecord::Migration
  def self.up
    rename_column :users, :accepted_license_agreement_version, :terms_of_use
    change_column :users, :terms_of_use, :boolean
    User.update_all(["terms_of_use = ?", false])
  end

  def self.down
    rename_column :users, :terms_of_use, :accepted_license_agreement_version
    change_column :users, :accepted_license_agreement_version, :string
  end
end

class RenameLicenseAgreementVersionToTosAccepted < ActiveRecord::Migration
  def self.up
    remove_column :users, :accepted_license_agreement_version
    add_column :users, :terms_of_use, :boolean, :default => false
  end

  def self.down
    rename_column :users, :terms_of_use, :accepted_license_agreement_version
    change_column :users, :accepted_license_agreement_version, :string
  end
end

Fix error with migration on PostgreSQL
Fix error with migration on PostgreSQL

In PostgreSQL, changing a column type from varchar to boolean doesn't
automatically convert the contents as MySQL does. Therefore we remove
the old column and add the new one instead of changing the type.
