I'm using Rails and Postgres. I currently have a Like table created. I need to drop this table and re-create it. Here's what I've done so far.
PG::DuplicateTable: ERROR: relation "likes" already exists
Old migrations don't run when you change their content, and you should not rename them. Even if they did run, changing the
create_table :likes to
create_table :old_likes cannot possibly change the name of an existing table. That isn't what
create_table does. At best, re-running that migration will now cause a new table to be created called
old_likes, with no content, while leaving your old
likes table unaffected. In actuality re-running that migration will simply fail, as it will attempt to undo the migration first, dropping the table
old_likes which does not yet exist.
What you need to do is create a new migration called
rename_likes_to_old_likes, which actually renames the table, using
rename_table. Then, either:
create_new_likes_tableor the like, and introduce your new table there.