migration

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultMigrationOptions = &gormigrate.Options{
	TableName:      "migrations",
	IDColumnName:   "id",
	IDColumnSize:   255,
	UseTransaction: true,
}

DefaultMigrationOptions contains default options for the gormigrate package

Functions

func CreateMigration

func CreateMigration(db *sql.DB, dir, name, migrationType string) error

CreateMigration creates a new migration file

func Down

func Down(db *sql.DB, dir, dialect string) error

Down rolls back a single migration

func DownTo

func DownTo(db *sql.DB, dir, dialect string, version int64) error

DownTo rolls back to a specific version

func ExecMultiple

func ExecMultiple(tx *gorm.DB, sqls string) error

ExecMultiple executes multiple SQL sentences

func GetStatus

func GetStatus(db *sql.DB, dir, dialect string) error

GetStatus returns the current migration status

func GetVersion

func GetVersion(db *sql.DB) (int64, error)

GetVersion returns the current database version

func Redo

func Redo(db *sql.DB, dir, dialect string) error

Redo rolls back the most recent migration, then runs it again

func Reset

func Reset(db *sql.DB, dir, dialect string) error

Reset rolls back all migrations

func Run

func Run(db *gorm.DB, migrations []*gormigrate.Migration)

Run executes the migrations given

func RunGoose

func RunGoose(db *sql.DB, cfg *GooseConfig) error

RunGoose initializes and runs goose migrations

func UpByOne

func UpByOne(db *sql.DB, dir, dialect string) error

UpByOne migrates up by a single version

func UpTo

func UpTo(db *sql.DB, dir, dialect string, version int64) error

UpTo migrates up to a specific version

Types

type GooseConfig

type GooseConfig struct {
	Dir          string // Directory containing migration files
	TableName    string // Migration table name (default: goose_db_version)
	Dialect      string // Database dialect: mysql, postgres, sqlite3
	Verbose      bool   // Enable verbose logging
	AllowMissing bool   // Allow missing (out-of-order) migrations
}

GooseConfig contains configuration for goose migrations

func DefaultGooseConfig

func DefaultGooseConfig() *GooseConfig

DefaultGooseConfig returns default configuration for goose

Jump to

Keyboard shortcuts

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