---
title: PostgreSQL Store
description: Production-ready PostgreSQL store using grove ORM with pgdriver.
---

The `store/postgres` package implements Dispatch's store interfaces using the grove ORM with the PostgreSQL driver. It is the recommended store for production deployments.

## Usage

```go
import (
    "github.com/xraph/grove"
    "github.com/xraph/grove/drivers/pgdriver"
    "github.com/xraph/dispatch/store/postgres"
)

db, err := grove.Open(pgdriver.Open("postgres://user:pass@localhost:5432/dispatch?sslmode=disable"))
if err != nil {
    log.Fatal(err)
}

s := postgres.New(db)
if err := s.Migrate(ctx); err != nil {
    log.Fatal(err)
}

d, err := dispatch.New(dispatch.WithStore(s))
```

## Migrations

Call `s.Migrate(ctx)` before first use. This creates all required tables and indexes. Migrations are idempotent -- safe to run on every startup.

## Internals

| Aspect | Detail |
|--------|--------|
| Driver | grove ORM + pgdriver |
| Migrations | grove orchestrator with embedded SQL migrations |
| Transactions | Database-level ACID |
| Ping | `db.Ping(ctx)` |
| Close | No-op -- caller owns the `*grove.DB` lifecycle |

## When to use

- Production deployments requiring ACID transactions and full SQL query power.
- Multi-process environments with connection pooling.
- When you need durable storage for jobs, workflows, and events.
