Hi,
Is there a way to specify parameters to :drop_table?
":create_table" has :options, but ":drop_table" does not.
Before creating tables using migrations, I need to drop them in a
particular order, due to foreign keys. To do this, I need to specify
the SQL "if exists" condition. Is there a parameter for doing this?
I've resorted to wrapping each ":drop_table" in a begin... rescue
block, but was wondering if there was a better way?
begin
drop_table :my_table
rescue Exception => exc
puts "Error1: #{exc}"
end
Hi Jan,
Yes, the :force would work, but because of foreign keys, I need to drop
all tables first, and in reverse order of creating them. If there is
any data, a drop_table fails because it would violate a fk requirements
on a different table.
I could also use the execute command to call the drop table command
myself, but that would be DB specific. Or empty the tables first. I
think that may work too.