views:

14

answers:

1

I have no problem with adding the foreign key constraint with this gem:

http://github.com/matthuhiggins/foreigner

However, I cannot remove the foreign key.

class ForeignKeys < ActiveRecord::Migration
  def self.up
    add_foreign_key(:threads, :users)
  end

  def self.down
    remove_foreign_key(:threads, :column => :user_id)
  end
end

Could someone help me out here.

Thanks.

+1  A: 

This the last thing I can think of.

def self.down
    execute 'ALTER TABLE threads DROP FOREIGN KEY user_id'
end

OLD ONE

These should work :)

remove_foreign_key :threads, { :column => :user_id }

or

remove_foreign_key('threads', 'user_id')

or

remove_foreign_key(:threads, :user_id)

Petr

praethorian
weird. it didnt work :(
never_had_a_name
I edited my first entry. It must work :)
praethorian
havent tried it yet, but i know it works =)
never_had_a_name