Re-adding constraint after ALTER fails on row that exists
If you get that message although the image_id is present in mcqueen_base_image, you must be dealing with data corruption.

Try to

REINDEX mcqueen_base_image;


and see if the problem persists.

If there are still problems, you'll have to repair the data manually. Then


dump and restore the database to a new cluster to get rid of any lingering data corruption.
investigate the cause of the corruption.