Skip to content

Commit f724bb5

Browse files
docs: mention new migration providers
1 parent d96f01f commit f724bb5

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,25 @@ Choose either one of these PostgreSQL drivers:
3737
- `github.com/andrei-polukhin/pgdbtemplate-pgx` (for `pgx/v5` with connection pooling)
3838
- `github.com/andrei-polukhin/pgdbtemplate-pq` (for `database/sql` with `lib/pq`)
3939

40+
## Migration Library Support
41+
42+
`pgdbtemplate` supports multiple migration libraries through dedicated adapters:
43+
44+
- **[goose](https://github.com/andrei-polukhin/pgdbtemplate-goose)** - Popular migration tool with broad feature set
45+
- **[golang-migrate](https://github.com/andrei-polukhin/pgdbtemplate-golang-migrate)** - Widely-used CLI and library
46+
- **[Atlas](https://github.com/andrei-polukhin/pgdbtemplate-atlas)** - Modern declarative migration tool
47+
48+
Or use the built-in file-based migration runner for simple SQL migrations.
49+
50+
```bash
51+
# Choose your migration adapter
52+
go get github.com/andrei-polukhin/pgdbtemplate-goose
53+
# or
54+
go get github.com/andrei-polukhin/pgdbtemplate-golang-migrate
55+
# or
56+
go get github.com/andrei-polukhin/pgdbtemplate-atlas
57+
```
58+
4059
## Quick Start
4160

4261
```go
@@ -428,6 +447,17 @@ between tests.
428447
- PostgreSQL 9.5+ (for template database support)
429448
- Go 1.20+
430449

450+
## Related Projects
451+
452+
### Connection Providers
453+
- [pgdbtemplate-pq](https://github.com/andrei-polukhin/pgdbtemplate-pq) - `lib/pq` (`database/sql`) connection provider
454+
- [pgdbtemplate-pgx](https://github.com/andrei-polukhin/pgdbtemplate-pgx) - `pgx/v5` connection provider with pooling
455+
456+
### Migration Adapters
457+
- [pgdbtemplate-goose](https://github.com/andrei-polukhin/pgdbtemplate-goose) - [goose](https://github.com/pressly/goose) migration adapter
458+
- [pgdbtemplate-golang-migrate](https://github.com/andrei-polukhin/pgdbtemplate-golang-migrate) - [golang-migrate](https://github.com/golang-migrate/migrate) adapter
459+
- [pgdbtemplate-atlas](https://github.com/andrei-polukhin/pgdbtemplate-atlas) - [Atlas](https://atlasgo.io/) migration adapter
460+
431461
## Contributors
432462

433463
We appreciate all the contributors who have helped make this project better!

docs/COMPARISON.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
## Analysis of [`pgtestdb`](https://github.com/peterldowns/pgtestdb)
44

5-
*Analysis conducted on September 21, 2025*
5+
*Analysis conducted on September 21, 2025*
6+
*Updated on October 11, 2025*
67

78
This comparison examines `pgtestdb` as a notable competitor
89
in the PostgreSQL testing space. By analysing competing solutions,
@@ -13,11 +14,11 @@ and project requirements.
1314

1415
| Category | `pgdbtemplate` | `pgtestdb` | Winner & Rationale |
1516
| :--- | :--- | :--- | :--- |
16-
| **Architecture & Dependencies** | **Fully driver-agnostic.** Clean interfaces (`ConnectionProvider`, `MigrationRunner`). Users explicitly choose and import only the needed driver (`pgdbtemplate-pgx` or `pgdbtemplate-pq`). | **Tightly coupled to `database/sql`.** Users must pass driver names (`"pgx"`, `"postgres"`) as strings, requiring imports of both drivers even when using only one. | **pgdbtemplate**. Modern, clean architecture without implicit dependencies. |
17+
| **Architecture & Dependencies** | **Fully driver-agnostic.** Clean interfaces (`ConnectionProvider`, `MigrationRunner`). Users explicitly choose and import only the needed driver (`pgdbtemplate-pgx` or `pgdbtemplate-pq`) and migration adapter if needed. | **Tightly coupled to `database/sql`.** Users must pass driver names (`"pgx"`, `"postgres"`) as strings, requiring imports of both drivers even when using only one. | **pgdbtemplate**. Modern, clean architecture without implicit dependencies. |
1718
| **Flexibility & Control** | **High.** Separation of concerns: dedicated connection provider and migration runner. Full support for custom implementations. Explicit control over pooling and connection settings. | **Low.** Monolithic `Config` and `Migrator`. Connection settings and migration logic are mixed. Less control over pooling and connection lifecycle. | **pgdbtemplate**. Gives developers complete control over all database aspects. |
1819
| **Performance** | **~28.2–28.8ms per DB** (consistent). **+37% faster** on 200 DBs. Detailed benchmarks analysing schema complexity impact. | Claims **"~10ms per clone"**, but lacks detailed public benchmarks and methodology. | **pgdbtemplate**. Performance backed by data and is a key differentiator. |
1920
| **Security & Enterprise** | **Explicit lifecycle management** (`Initialize`, `Cleanup`). Thread-safe. Support for ready-made pooling options (`MaxConns`, `MinConns`, `Lifetime`). | **Magic database creation inside tests.** Automatic cleanup only if tests pass. May be non-deterministic in complex scenarios. | **pgdbtemplate**. Predictability and control are critical in enterprise environments. |
20-
| **Migration Handling** | **Simple and straightforward.** `FileMigrationRunner` for SQL files or custom interface implementations. | **Strong suit.** Wide selection of built-in adapters for popular migration frameworks (`goose`, `golang-migrate`, `atlas`, etc.). | **pgtestdb**. Wins due to extensive out-of-the-box adapter support. |
21+
| **Migration Handling** | **Flexible and modular.** Built-in `FileMigrationRunner` for SQL files. Dedicated adapters for popular frameworks: [goose](https://github.com/andrei-polukhin/pgdbtemplate-goose), [golang-migrate](https://github.com/andrei-polukhin/pgdbtemplate-golang-migrate), [Atlas](https://github.com/andrei-polukhin/pgdbtemplate-atlas). Each adapter is a separate module - import only what you need. | **Strong suit.** Wide selection of built-in adapters for popular migration frameworks (`goose`, `golang-migrate`, `atlas`, etc.), but all bundled in one package. | **Tie**. Both support major migration frameworks. `pgdbtemplate` offers better modularity; `pgtestdb` offers more convenience. |
2122
| **User Experience (UX)** | **More verbose,** but more explicit. Requires understanding the architecture. Ideal for long-term and complex projects. | **Simpler to start.** `pgtestdb.New(t, config, migrator)` returns a ready `*sql.DB`. Quick adoption. | **pgtestdb**. Better for rapid prototyping and smaller projects. |
2223
| **Testing Design** | **Dependency injection.** You receive connection and its name to pass to your repository or service. | **Dependency creation inside test.** Library creates and injects `*sql.DB` itself, which may violate application architecture. | **pgdbtemplate**. Promotes clean architecture and DI. |
2324
| **Output Verbosity** | Minimal. Operates quietly. | **Detailed logging.** Logs connection strings for debugging on test failures, which may clutter output. | **Tie.** Depends on preferences: silence vs. debug information. |
@@ -33,13 +34,15 @@ and project requirements.
3334
3. **Thread safety and predictability.** Critical for large projects with parallel tests.
3435
4. **Flexibility.** Easily integrates into any existing application architecture
3536
through dependency injection.
37+
5. **Modular migration support.** Dedicated adapters for popular frameworks as separate,
38+
optional modules. Import only what you need, keeping dependencies minimal.
3639

3740
**`pgtestdb`** positions itself as
3841
"the tool for quick starts and projects with diverse migrations".
3942

4043
**Strengths:**
4144
1. **Ease of initial setup.** One function call and you're writing tests.
42-
2. **Extensive migration framework support.** No need to write custom `MigrationRunner`.
45+
2. **Bundled migration framework support.** All adapters in one package.
4346
3. **Automation.** Self-cleanup after successful tests.
4447

4548
### Choosing the Right Tool
@@ -49,10 +52,11 @@ and project requirements.
4952
- Architectural flexibility and explicit control
5053
- Enterprise-grade predictability and thread safety
5154
- Integration with existing dependency injection patterns
55+
- Modular dependencies - import only the driver and migration adapter you actually use
5256

5357
**Choose `pgtestdb` if you prioritise:**
5458
- Rapid prototyping and quick setup
55-
- Support for multiple migration frameworks out-of-the-box
59+
- All migration adapters bundled in one package (convenience over modularity)
5660
- Minimal configuration for smaller projects
5761

5862
This analysis demonstrates our commitment to transparency and

0 commit comments

Comments
 (0)