migrate

package
v1.6.6 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTableName = "bingo_migration"

Default table name for migration records

Variables

This section is empty.

Functions

func Add

func Add(name string, up migrationFunc, down migrationFunc)

func SetTableName added in v1.5.3

func SetTableName(name string)

SetTableName sets the migration table name

Types

type Migration

type Migration struct {
	ID        uint64 `gorm:"primaryKey;autoIncrement;"`
	Migration string `gorm:"type:varchar(255);not null;unique;"`
	Batch     int
}

func (Migration) TableName added in v1.5.2

func (Migration) TableName() string

TableName returns the configured migration table name

type MigrationFile

type MigrationFile struct {
	Up       migrationFunc
	Down     migrationFunc
	FileName string
}

func GetMigrationFile

func GetMigrationFile(name string) MigrationFile

type Migrator

type Migrator struct {
	DB       *gorm.DB
	Migrator gorm.Migrator
}

func NewMigrator

func NewMigrator(db *gorm.DB) *Migrator

NewMigrator creates a new Migrator with default table name.

func NewMigratorWithTable added in v1.5.2

func NewMigratorWithTable(db *gorm.DB, tableName string) *Migrator

NewMigratorWithTable creates a new Migrator with custom table name. If tableName is empty, uses the value from environment variable or default.

func (*Migrator) DeleteAllTables

func (migrator *Migrator) DeleteAllTables() error

func (*Migrator) Fresh

func (migrator *Migrator) Fresh()

func (*Migrator) Refresh

func (migrator *Migrator) Refresh()

func (*Migrator) Reset

func (migrator *Migrator) Reset()

func (*Migrator) Rollback

func (migrator *Migrator) Rollback()

func (*Migrator) Up

func (migrator *Migrator) Up()

Directories

Path Synopsis
ABOUTME: Calculates checksum of migration files for cache invalidation ABOUTME: Uses SHA256 hash of all .go files in migration directory
ABOUTME: Calculates checksum of migration files for cache invalidation ABOUTME: Uses SHA256 hash of all .go files in migration directory

Jump to

Keyboard shortcuts

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