postgres

package
v0.0.0-...-02e3363 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package postgres wires VersionGate to its PostgreSQL database: connection pooling and schema migrations (specs/decisions/database.md). It is infrastructure — nothing under internal/version or future domain packages may import it (.rules/architecture.md).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MigrateDown

func MigrateDown(ctx context.Context, db *sql.DB) error

MigrateDown rolls back the most recently applied migration.

func MigrateUp

func MigrateUp(ctx context.Context, db *sql.DB) error

MigrateUp applies all pending migrations.

func MigrationStatus

func MigrationStatus(ctx context.Context, db *sql.DB) ([]*goose.MigrationStatus, error)

MigrationStatus returns the applied/pending status of every known migration, in order.

func Open

func Open(ctx context.Context, dsn string) (*sql.DB, error)

Open connects to Postgres using dsn and verifies connectivity before returning, so a misconfigured or unreachable database fails clearly at startup rather than on the first query.

Types

type ApplicationRepository

type ApplicationRepository struct {
	// contains filtered or unexported fields
}

ApplicationRepository is a PostgreSQL-backed implementation of application.Repository.

func NewApplicationRepository

func NewApplicationRepository(db *sql.DB) *ApplicationRepository

NewApplicationRepository builds an ApplicationRepository backed by db.

func (*ApplicationRepository) Create

func (r *ApplicationRepository) Create(ctx context.Context, projectID project.ID, identifier, displayName string, platform application.Platform) (application.Application, error)

func (*ApplicationRepository) Deactivate

func (*ApplicationRepository) Get

func (*ApplicationRepository) GetByIdentifier

func (r *ApplicationRepository) GetByIdentifier(ctx context.Context, identifier string) (application.Application, error)

GetByIdentifier looks up an Application by identifier alone, across all Projects — see application.Repository.GetByIdentifier's doc comment for why, and for ErrIdentifierAmbiguous's meaning. LIMIT 2 (rather than 1) is deliberate: it lets this method distinguish "found exactly one" from "found more than one" in a single query.

type ProjectRepository

type ProjectRepository struct {
	// contains filtered or unexported fields
}

ProjectRepository is a PostgreSQL-backed implementation of project.Repository.

func NewProjectRepository

func NewProjectRepository(db *sql.DB) *ProjectRepository

NewProjectRepository builds a ProjectRepository backed by db.

func (*ProjectRepository) Create

func (r *ProjectRepository) Create(ctx context.Context, name string) (project.Project, error)

func (*ProjectRepository) Deactivate

func (r *ProjectRepository) Deactivate(ctx context.Context, id project.ID) (project.Project, error)

func (*ProjectRepository) Get

type ReleaseRepository

type ReleaseRepository struct {
	// contains filtered or unexported fields
}

ReleaseRepository is a PostgreSQL-backed implementation of release.Repository. It relies entirely on the database's unique constraint on (application_id, major, minor, patch, build_number) to detect duplicates — Create makes no separate existence check before inserting, so it is safe under concurrent or retried calls.

func NewReleaseRepository

func NewReleaseRepository(db *sql.DB) *ReleaseRepository

NewReleaseRepository builds a ReleaseRepository backed by db.

func (*ReleaseRepository) Create

func (r *ReleaseRepository) Create(ctx context.Context, applicationID application.ID, v version.Version, buildNumber int, policy release.Policy) (release.Release, error)

func (*ReleaseRepository) GetByVersion

func (r *ReleaseRepository) GetByVersion(ctx context.Context, applicationID application.ID, v version.Version, buildNumber int) (release.Release, error)

func (*ReleaseRepository) ListByApplication

func (r *ReleaseRepository) ListByApplication(ctx context.Context, applicationID application.ID) ([]release.Release, error)

type TokenRepository

type TokenRepository struct {
	// contains filtered or unexported fields
}

TokenRepository is a PostgreSQL-backed implementation of token.Repository. It only ever reads or writes token_hash — the raw token value never reaches this package.

func NewTokenRepository

func NewTokenRepository(db *sql.DB) *TokenRepository

NewTokenRepository builds a TokenRepository backed by db.

func (*TokenRepository) Create

func (r *TokenRepository) Create(ctx context.Context, projectID project.ID, tokenHash string) (token.Token, error)

func (*TokenRepository) GetByHash

func (r *TokenRepository) GetByHash(ctx context.Context, tokenHash string) (token.Token, error)

func (*TokenRepository) Revoke

func (r *TokenRepository) Revoke(ctx context.Context, id token.ID) (token.Token, error)

Jump to

Keyboard shortcuts

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