Skip to content

postgres ​

go
import "github.com/prescriptoo/prescriptoo-api/services/development/internal/adapters/postgres"

Package postgres implements development database operations using shared SQL routines.

Index ​

Variables ​

ErrUnavailable indicates that no database was configured.

go
var ErrUnavailable = errors.New("development database is not configured")

type Repository ​

Repository runs PostgreSQL operations without depending on service ports. The gate serializes development operations within this API process.

go
type Repository struct {
    // contains filtered or unexported fields
}

func NewRepository ​

go
func NewRepository(db *pgxpool.Pool) *Repository

NewRepository supports a nil pool for offline OpenAPI generation.

func (*Repository) ApplyAllMigrations ​

go
func (r *Repository) ApplyAllMigrations(ctx context.Context) (err error)

ApplyAllMigrations applies pending migrations in dependency order.

func (*Repository) Clean ​

go
func (r *Repository) Clean(ctx context.Context) error

Clean truncates application data while retaining schemas and migration history.

func (*Repository) MigrationStatus ​

go
func (r *Repository) MigrationStatus(ctx context.Context) (statuses []database.MigrationStatus, err error)

MigrationStatus returns structured status for every service's migrations.

func (*Repository) ResetDatabase ​

go
func (r *Repository) ResetDatabase(ctx context.Context) (err error)

ResetDatabase rolls back and reapplies all migrations, without seeding.

func (*Repository) Seed ​

go
func (r *Repository) Seed(ctx context.Context, password string, items []database.SeedItem) error

Seed loads the same repeatable datasets as the CLI, in dependency order. Each dataset has its own transaction; completed items survive a later failure.

Generated by gomarkdoc

Documentation follows the source. Planned contracts are marked explicitly.