Help us shape the future of Go! Take the 2026 Go Developer Survey

migration

package
v2.1.8 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Migration

type Migration struct {
	data.BaseModel

	Name        string `gorm:"type:text;uniqueIndex:idx_migrations_name"`
	Patch       string `gorm:"type:text"`
	RevertPatch string `gorm:"type:text"`
	AppliedAt   sql.NullTime
}

Migration Our simple table holding all the migration data.

type Migrator

type Migrator interface {
	DB(ctx context.Context) *gorm.DB
	ScanMigrationFiles(ctx context.Context, migrationsDirPath string) error
	SaveMigrationString(
		ctx context.Context,
		filename string,
		migrationPatch string,
		revertPatch string,
	) error
	ApplyNewMigrations(ctx context.Context) error
}

func NewMigrator

func NewMigrator(ctx context.Context, dbGetter func(ctx context.Context) *gorm.DB) Migrator

type Patch

type Patch struct {
	// Name is a simple description/name of this migration.
	Name string
	// Patch is the SQL to execute for an upgrade.
	Patch string
	// RevertPatch is the SQL to execute for a downgrade.
	RevertPatch string
}

Jump to

Keyboard shortcuts

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