Skip to content
Search

Pgdbtemplate

lastmod 2025-10-20created 2025-10-201 edits

Creating PostgreSQL test DBs ultra-fast with template DBs

About

  • A high-performance Go library that creates test DBs instantly by cloning a template database, minimizing migration costs
  • The goal is to accelerate test infrastructure by cutting test run time and safely handling large-scale parallel DB creation
  • 1.2–1.6x faster test DB creation than traditional create+migrate, scales up to 500 DBs, and ~17% memory savings
  • The benefit grows as the schema gets more complex, and its concurrency-safe, thread-safe design makes it suitable for parallel tests
  • Supports both the pq and pgx drivers, and integrates with Testcontainers
  • By implementing and swapping in a custom ConnectionProvider and MigrationRunner, it can be fine-tuned to in-house infrastructure, migration tools, and CI constraints

See also

Favorite site

author Zer0 sitemap