TLDR Dev · ARTICLES & TUTORIALS

DON'T RUN SQL MIGRATIONS IN TESTS: HOW I SPED UP THE TEST SUITE BY 2X

gaultier.github.io12 min read

Summary from the TLDR Dev newsletter

Large Go test suites often face slowdowns when thousands of SQL migrations are applied serially for every individual test. To address this, a content-addressing system identifies a "golden" database file by hashing the contents of all required migration scripts. If a matching database already exists, the system clones it instantly using a backup API, whereas missing versions are lazily generated and cached for subsequent runs.