class AddTextfilterToUsers < ActiveRecord::Migration
  def self.up
    f = TextFilter.find(:first, :conditions => 'name = "none"')
    add_column :users, :text_filter_id, :string, :default => f.id

    unless Blog.default.nil?
      t = TextFilter.find(:first, :conditions => "name= '#{Blog.default.text_filter}'")
      User.find(:all).each do |user|
        STDERR.puts "Adding textfilter #{t.name} to #{user.login}"
        user.text_filter_id = t.id
        user.save
      end
    end    
  end

  def self.down
    remove_column :text_filter_id, :integer
  end
end
class AddTextfilterToUsers < ActiveRecord::Migration
  def self.up
    f = TextFilter.find(:first, :conditions => ["name = ?", "none"])
    add_column :users, :text_filter_id, :string, :default => f.id

    unless Blog.default.nil?
      t = TextFilter.find(:first, :conditions => "name= '#{Blog.default.text_filter}'")
      User.find(:all).each do |user|
        STDERR.puts "Adding textfilter #{t.name} to #{user.login}"
        user.text_filter_id = t.id
        user.save
      end
    end    
  end

  def self.down
    remove_column :text_filter_id, :integer
  end
end

Make migration succeed on PostgreSQL
Make migration succeed on PostgreSQL

Signed-off-by: Frédéric de Villamil <58692fd42329d32571d999fbcdd2ddd08a5186db@de-villamil.com>