migration

package
v1.69.3 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 12 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