Validate PostgreSQL Schema After Years Of Upgrades

I’m not a rails developer so not sure if the migration system or runtime already has some validation or not. However, after years of using Gitlab, we’ve occasionally had failed migrations. Which when we --trace, we’re given a rake task to simply mark the migration as complete. We didn’t always document these in the past to come back around and validate that our schema is in line with the specific migrations we had issues with.

I was wondering if there was a simple way to do a sanity check to make sure that our running schema is in line with all of the migrations over history? I don’t want a future migration that drops an index for example, to fail because we never actually added the expected index 3 years ago.

Short of an easy way to do this within Gitlab or rails. I was just going to install the latest Gitlab on a new server, and dump the schema. Then dump the schema from my running instance and literally do a diff to see if anything jumps out.