Help us shape the future of Go! Take the 2026 Go Developer Survey

database

package
v0.0.0-...-79528b0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 11 Imported by: 0

README

Persistence Layer and Database Schema

This document outlines the data storage architecture, migration workflows, and seeding strategies for the PostgreSQL primary transactional database.

PostgreSQL Configuration

The system utilizes PostgreSQL 17-alpine as its primary OLTP store, configured for high-availability using a primary-replica topology.

Logical Schema Organization
  • Authentication: Identity stores, role-based access control (RBAC), and session metadata.
  • Core Transactions: Atomic records of all financial events including status, type, and cross-reference identifiers.
  • Balances: Real-time ledger accounting for all user and merchant entities.

Migration Framework

Schema evolutions are managed using the goose migration tool. All migrations are version-controlled and idempotent.

To apply migrations locally:

just migrate

Migrations are located in pkg/database/migrations/.

Data Seeding Strategy

For performance testing and development parity, a high-volume seeding engine is implemented.

  • Go Seeders: Programmatic data generation located in pkg/database/seeder/.
  • SQL Seeds: A high-fidelity seeder.sql containing a baseline of 100+ users and 1,500+ heterogeneous records.

To seed the database:

just seeder

Connection Pooling

PgBouncer is utilized for server-side connection pooling to prevent saturation of the PostgreSQL backend during high-concurrency event bursts. All microservices connect to PostgreSQL via the pgbouncer service endpoint.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsUniqueViolation

func IsUniqueViolation(err error) bool

IsUniqueViolation reports whether err is a PostgreSQL unique constraint violation (SQLSTATE 23505).

func NewClient

func NewClient(logger logger.LoggerInterface) (*pgxpool.Pool, error)

func NewClientA

func NewClientA(logger logger.LoggerInterface) (*pgxpool.Pool, error)

func NewClientB

func NewClientB(logger logger.LoggerInterface) (*pgxpool.Pool, error)

func NewClientC

func NewClientC(logger logger.LoggerInterface) (*pgxpool.Pool, error)

func NewClientD

func NewClientD(logger logger.LoggerInterface) (*pgxpool.Pool, error)

func NewClientWithPrefix

func NewClientWithPrefix(logger logger.LoggerInterface, prefix string) (*pgxpool.Pool, error)

func RunMigrations

func RunMigrations(log logger.LoggerInterface, path string) error

RunMigrations executes database migrations using goose. path: directory containing migration files.

Types

This section is empty.

Directories

Path Synopsis
Package models holds transport-agnostic domain types shared between services.
Package models holds transport-agnostic domain types shared between services.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL