migration

package
v1.0.0-alpha.21 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

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

Migrate applies all pending migrations to db. It is idempotent: already-applied migrations are skipped.

Concurrent callers — parallel test packages sharing one database, or several nodes starting at once — are serialized with a lease row in lockTable: goose's Up is not concurrency-safe, so two concurrent runs can both see a migration as pending and race its DDL (plain CREATE TABLE, no IF NOT EXISTS) or the goose_db_version bookkeeping insert. Waiters poll the lease with read-only queries only; on the emulator a read-write transaction in flight would make the holder's DDL fail.

The holder renews the lease while goose runs, so schema changes that outlive leaseSeconds keep their lease, and goose executes under a fencing context: the moment holdership can no longer be proven — another holder took the row, or renewal failed for a full lease window — the context is canceled and the fenced holder stops instead of racing its successor.

Types

This section is empty.

Jump to

Keyboard shortcuts

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