postgres
import "github.com/prescriptoo/prescriptoo-api/services/development/internal/adapters/postgres"Package postgres implements development database operations using shared SQL routines.
Index
- Variables
- type Repository
- func NewRepository(db *pgxpool.Pool) *Repository
- func (r *Repository) ApplyAllMigrations(ctx context.Context) (err error)
- func (r *Repository) Clean(ctx context.Context) error
- func (r *Repository) MigrationStatus(ctx context.Context) (statuses []database.MigrationStatus, err error)
- func (r *Repository) ResetDatabase(ctx context.Context) (err error)
- func (r *Repository) Seed(ctx context.Context, password string, items []database.SeedItem) error
Variables
ErrUnavailable indicates that no database was configured.
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.
type Repository struct {
// contains filtered or unexported fields
}func NewRepository
func NewRepository(db *pgxpool.Pool) *RepositoryNewRepository supports a nil pool for offline OpenAPI generation.
func (*Repository) ApplyAllMigrations
func (r *Repository) ApplyAllMigrations(ctx context.Context) (err error)ApplyAllMigrations applies pending migrations in dependency order.
func (*Repository) Clean
func (r *Repository) Clean(ctx context.Context) errorClean truncates application data while retaining schemas and migration history.
func (*Repository) MigrationStatus
func (r *Repository) MigrationStatus(ctx context.Context) (statuses []database.MigrationStatus, err error)MigrationStatus returns structured status for every service's migrations.
func (*Repository) ResetDatabase
func (r *Repository) ResetDatabase(ctx context.Context) (err error)ResetDatabase rolls back and reapplies all migrations, without seeding.
func (*Repository) Seed
func (r *Repository) Seed(ctx context.Context, password string, items []database.SeedItem) errorSeed 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