We use ActiveRecord migrations for our application. I’m trying to optimize our test initialization time by avoiding running migrations when possible. A common pattern that happens is a developer will introduce a new migration, and then modify the file to iterate on the schema while working on their feature. Rails sees that the migration timestamp is present in the schema_migrations table, and won’t re-run the migration.
If ActiveRecord also stored a hash of the migration text (ie all the code that Rails sends to the database server), then it could be determined whether or not a migration has changed from when Rails initially ran the migration. This would be helpful for our cache avoidance - we’d check each migration’s presence in the version and then if the hashes match. If they match, then we have a good cache, and can avoid redoing work.