migrations

package
v0.0.0-...-333b13f Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: OSL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMigrationVersion

func GetMigrationVersion(ctx context.Context, pool *pgxpool.Pool, migrationsPath string) (uint, bool, error)

GetMigrationVersion returns the current migration version.

func MigrateToVersion

func MigrateToVersion(ctx context.Context, pool *pgxpool.Pool, migrationsPath string, version uint) error

MigrateToVersion migrates the schema up or down to exactly the given version. Unlike RunMigrations it applies no post-migration Go logic (admin seeding etc.), and unlike RollbackMigrations it targets a version rather than a step count. Migration tests use it to pin the database at the version just below the migration under test; fixed step counts from head silently drift every time a newer migration lands.

func RollbackMigrations

func RollbackMigrations(ctx context.Context, pool *pgxpool.Pool, migrationsPath string, steps int) error

RollbackMigrations rolls back N migrations.

func RunMigrations

func RunMigrations(ctx context.Context, pool *pgxpool.Pool, migrationsPath, adminEmail, adminPassword string) error

RunMigrations runs database migrations using golang-migrate adminEmail is optional - if provided, admin user will be created after migrations complete adminPassword is optional - if provided, admin is created with hashed password and active=true.

ctx bounds the schema work itself: connection setup, advisory-lock wait and the running migration SQL. When ctx ends, the migrator's connections are canceled server-side and RunMigrations returns an error matching errors.Is(err, ctx.Err()). An interrupted migration rolls back (every migration is transactional) but leaves schema_migrations dirty, which the next run reports through maybeAutoHealDirty.

func ValidateMigrationsPath

func ValidateMigrationsPath(path string) error

ValidateMigrationsPath checks if migrations directory exists.

Types

This section is empty.

Jump to

Keyboard shortcuts

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