1 year ago

Can you remove a foreign key reference without dropping the column entirely?

Posted 1 year ago by nexxai

Say I used these lines in a migration:


Now say later in development, I realized that I should have generalized better and so what I want to do is rename the "dogs" table to "pets". I rename the table to "pets" and rename columns to "pet_id" and that all works, but the foreign key relationship is still pointing to the "dogs" table. Do I just do:


and call it a day? If that actually drops all the data in that column then that's bad. Or is there something else I need to do too?


Please sign in or create an account to participate in this conversation.