Documentation
¶
Overview ¶
Package postgres provides a PostgreSQL driver for Queen migrations.
Index ¶
- type Driver
- func (d *Driver) Exec(ctx context.Context, isolationLevel sql.IsolationLevel, fn func(*sql.Tx) error) error
- func (d *Driver) ExecMigration(ctx context.Context, m *queen.Migration, isolation sql.IsolationLevel, ...) error
- func (d *Driver) ExecNonTransactional(ctx context.Context, m *queen.Migration, direction string) (retErr error)
- func (d *Driver) GetApplied(ctx context.Context) ([]queen.Applied, error)
- func (d *Driver) Init(ctx context.Context) error
- func (d *Driver) Lock(ctx context.Context, timeout time.Duration) error
- func (*Driver) LockBeforeInit()
- func (d *Driver) Record(ctx context.Context, m *queen.Migration, meta *queen.MigrationMetadata) error
- func (d *Driver) RecordTx(ctx context.Context, tx *sql.Tx, m *queen.Migration, ...) error
- func (d *Driver) Remove(ctx context.Context, version string) error
- func (d *Driver) RemoveTx(ctx context.Context, tx *sql.Tx, version string) error
- func (d *Driver) SetMigrationStatus(ctx context.Context, version, status string, durationMS int64) error
- func (d *Driver) Unlock(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
Driver implements the queen.Driver interface for PostgreSQL.
func NewFromPool ¶
NewFromPool creates a PostgreSQL driver from a native pgx pool.
The returned driver uses database/sql through pgx's stdlib adapter. Closing the driver closes only the adapter handle; it does not close the pgx pool.
func NewFromPoolWithTableName ¶
NewFromPoolWithTableName creates a PostgreSQL driver from a native pgx pool with a custom migration table name.
func NewWithTableName ¶
NewWithTableName creates a new PostgreSQL driver with a custom table name.
func (*Driver) Exec ¶
func (d *Driver) Exec(ctx context.Context, isolationLevel sql.IsolationLevel, fn func(*sql.Tx) error) error
Exec runs migrations on the connection holding the advisory lock. If that session is lost, the migration transaction is lost with it.
func (*Driver) ExecMigration ¶
func (d *Driver) ExecMigration(ctx context.Context, m *queen.Migration, isolation sql.IsolationLevel, fn func(*sql.Tx) error) error
ExecMigration sets PostgreSQL timeouts for the duration of one transaction.
func (*Driver) ExecNonTransactional ¶
func (d *Driver) ExecNonTransactional(ctx context.Context, m *queen.Migration, direction string) (retErr error)
ExecNonTransactional runs one SQL command on the lock-holding connection.
func (*Driver) GetApplied ¶
GetApplied reads through the lock connection when a migration holds it.
func (*Driver) Init ¶
Init creates or upgrades the migrations tracking table under the migration lock.
func (*Driver) LockBeforeInit ¶
func (*Driver) LockBeforeInit()
LockBeforeInit tells Queen that PostgreSQL can lock before table setup.
func (*Driver) Record ¶
func (d *Driver) Record(ctx context.Context, m *queen.Migration, meta *queen.MigrationMetadata) error
Record writes through the lock connection when the migration is non-transactional.
func (*Driver) RecordTx ¶
func (d *Driver) RecordTx(ctx context.Context, tx *sql.Tx, m *queen.Migration, meta *queen.MigrationMetadata) error
RecordTx records an applied migration in the migration transaction.
func (*Driver) Remove ¶
Remove writes through the lock connection when the migration is non-transactional.