{"modulePath":"github.com/LeanerCloud/cloud-commitments-platform","version":"v0.0.0-20261202160902-a99bcb5bfea3","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package migrations\n\n## Functions\n\n```go\nfunc GetMigrationVersion(ctx context.Context, pool *pgxpool.Pool, migrationsPath string) (version uint, dirty bool, err error)\n```\nGetMigrationVersion returns the current migration version. ctx bounds the advisory-lock wait and the version query like RunMigrations: when it ends the migrator's connections are canceled server-side and the error matches errors.Is(err, ctx.Err()).\n\n```go\nfunc MigrateToVersion(ctx context.Context, pool *pgxpool.Pool, migrationsPath string, version uint) error\n```\nMigrateToVersion 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.\n\n```go\nfunc RollbackMigrations(ctx context.Context, pool *pgxpool.Pool, migrationsPath string, steps int) error\n```\nRollbackMigrations rolls back N migrations.\n\n```go\nfunc RunMigrations(ctx context.Context, pool *pgxpool.Pool, migrationsPath, adminEmail, adminPassword string) error\n```\nRunMigrations 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.\n\nctx 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 file rolls back as a whole (PostgreSQL runs each file as one implicit transaction; see TestMigrationsAreTransactional) but leaves schema\\_migrations dirty, which the next run reports through maybeRefuseDirty without clearing it.\n\n```go\nfunc ValidateMigrationsPath(path string) error\n```\nValidateMigrationsPath checks if migrations directory exists.\n\n","path":"github.com/LeanerCloud/cloud-commitments-platform/internal/database/postgres/migrations","name":"migrations","synopsis":"","isRedistributable":true}
