postgres

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package postgres provides a PostgreSQL driver for Queen migrations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

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

Driver implements the queen.Driver interface for PostgreSQL.

func New

func New(db *sql.DB) *Driver

New creates a new PostgreSQL driver. The database connection should already be open and configured. The default migrations table name is "queen_migrations".

func NewWithTableName

func NewWithTableName(db *sql.DB, tableName string) *Driver

NewWithTableName creates a new PostgreSQL driver with a custom table name.

func (*Driver) Close

func (d *Driver) Close() error

Close closes the database connection.

func (*Driver) Exec

func (d *Driver) Exec(ctx context.Context, fn func(*sql.Tx) error) error

Exec executes a function within a transaction.

func (*Driver) GetApplied

func (d *Driver) GetApplied(ctx context.Context) ([]queen.Applied, error)

GetApplied returns all applied migrations sorted by applied_at.

func (*Driver) Init

func (d *Driver) Init(ctx context.Context) error

Init creates the migrations tracking table if it doesn't exist.

func (*Driver) Lock

func (d *Driver) Lock(ctx context.Context, timeout time.Duration) error

Lock acquires an advisory lock to prevent concurrent migrations. PostgreSQL advisory locks are automatically released when the connection closes or when explicitly unlocked.

func (*Driver) Record

func (d *Driver) Record(ctx context.Context, m *queen.Migration) error

Record marks a migration as applied.

func (*Driver) Remove

func (d *Driver) Remove(ctx context.Context, version string) error

Remove removes a migration record (for rollback).

func (*Driver) Unlock

func (d *Driver) Unlock(ctx context.Context) error

Unlock releases the advisory lock.

Jump to

Keyboard shortcuts

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