Docs/Controlplane/PostgreSQL Store
Open

Reading1 min
Updated31 Jul 2026
Sourcev1/stores/postgres.mdx

The PostgreSQL store (store/postgres) uses the Grove ORM with pgdriver to persist data in PostgreSQL. It is the recommended store for production SQL deployments.

When to use01

  • Production deployments -- battle-tested SQL database with ACID transactions.

  • PostgreSQL environments -- full query power, JSON operators, CTEs.

  • Multi-instance services -- shared database for horizontal scaling.

  • Teams familiar with SQL -- leverage existing database expertise.

Configuration02

import (
    "github.com/xraph/grove"
    "github.com/xraph/grove/drivers/pgdriver"
    "github.com/xraph/ctrlplane/store/postgres"
)

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

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

With the app

cp, err := app.New(
    app.WithStore(s),
)

Internals03

AspectDetail
DriverGrove ORM with pgdriver (PostgreSQL)
MigrationsGrove migration orchestrator with programmatic migrations
TransactionsPostgreSQL-level ACID transactions
ConcurrencyFull MVCC with row-level locking
MigrateCreates tables, indexes, constraints
Pingdb.Ping(ctx)
CloseCloses the database connection

Limitations04

  • External dependency -- requires a running PostgreSQL instance.

  • Schema migrations -- must run Migrate() before first use.

Comparison05

FeatureMemoryBadgerPostgreSQLSQLiteMongoDB
SetupNonePath onlyDSNFile pathURI
PersistenceNoYesYesYesYes
Multi-processNoNoYesNoYes
Query flexibilityLowLowHighMediumHigh
Best forTestsEmbedded KVProduction SQLEmbedded SQLProduction NoSQL