Search code examples
postgresqlpostgresql-12

Deleting duplicate constraints from pg_constraint left database in broken state


I had an issue with my database where I accidentally had 1000s of duplicate fkey constraints. I managed to find them & deleted directly from pg_constraint (I think this is where I messed up but it's too late now).

My data is all still there & the constraints I want but now the database spews "cache lookup failed for constraint".

What are my options here?

Is there anyway to repair the database? Do I just need to somehow get all my data out & restore a new database.


Solution

  • Only way that I could find was dumping the database & restoring a fresh one.