Skip to content

feat: local PostgreSQL container for query analysis / validation #4513

Description

@nikolayk812

What do you want to change?

sqlc query analysis requires a live PostgreSQL instance, but setting one up means either running a database separately. It also requires schema migration steps outside of sqlc.

Proposed change:

Add a testcontainers_image field to the database config block. When set, sqlc automatically starts a local PostgreSQL Docker container, applies schema migrations, and uses it for analysis — then tears it down when done.

  database:
    testcontainers_image: "postgres:18-alpine"

Mutually exclusive with uri and managed.

Pros:

  • Real PostgreSQL analysis without any external DB setup
  • Single config field replaces: start DB → apply migrations → pass URI

Scope:

  • New testcontainers_image config field (v1 + v2 schemas)
  • Validation: mutual exclusion with uri and managed
  • PostgreSQL only (initial support)
  • Container lifecycle managed by sqlc (start on first query, teardown on close)

What database engines need to be changed?

PostgreSQL

What programming language backends need to be changed?

Go

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions