How can I delete a tag in development database (on local)?

If I was doing this myself, I would start by going back to the site that the backup file was created on, delete the tag through the Rails console, then create a new backup file.

If that is not possible, or if it does not solve the duplicate tag issue, you could delete the row from the table by opening a psql terminal on it. Something like:

DELETE FROM tags WHERE name = <your_tag_name>;

My concern with this is that it will not remove usages of the deleted tag from the site’s database in the same way as is done if you use the Rails destroy! command. It might be a good idea to test this out on a copy of the backup file to make sure that it does not break anything.

It might also be a good idea to run a SELECT statement before deleting the tag. That might show the cause of the issue:

SELECT FROM tags WHERE name = <your_tag_name>;
1 Like