Documentation
¶
Index ¶
- Variables
- func NewDB(ctx context.Context, cfg *config.Database) (*sql.DB, error)
- type Migrator
- func (m *Migrator) Create(name string) (string, error)
- func (m *Migrator) Down(ctx context.Context, steps int) ([]*goose.MigrationResult, error)
- func (m *Migrator) DownAll(ctx context.Context) ([]*goose.MigrationResult, error)
- func (m *Migrator) Fresh(ctx context.Context) ([]*goose.MigrationResult, error)
- func (m *Migrator) Redo(ctx context.Context) ([]*goose.MigrationResult, []*goose.MigrationResult, error)
- func (m *Migrator) Status(ctx context.Context) ([]*goose.MigrationStatus, error)
- func (m *Migrator) Up(ctx context.Context, steps int) ([]*goose.MigrationResult, error)
- type Options
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrMigrationFailed = errors.New("migration failed")
Functions ¶
Types ¶
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
Migrator runs goose migrations against the application database.
Runtime operations (Up, Down, Status, Redo) use the embedded migration files compiled into the binary. Create writes new files to disk and is intended for development only.
func (*Migrator) Create ¶ added in v0.10.0
Create writes a new empty SQL migration file to disk. Development-only operation.
func (*Migrator) Down ¶ added in v0.10.0
Down rolls back applied migrations. Steps must be > 0, or use DownAll.
func (*Migrator) Fresh ¶ added in v0.10.0
Fresh drops all tables and re-applies all migrations from scratch. Development-only operation — equivalent to Laravel's migrate:fresh.
func (*Migrator) Redo ¶ added in v0.10.0
func (m *Migrator) Redo(ctx context.Context) ([]*goose.MigrationResult, []*goose.MigrationResult, error)
Redo rolls back the last migration and re-applies only that one migration.
Click to show internal directories.
Click to hide internal directories.