migration

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterMigration

func RegisterMigration(migration *Migration)

func ResetMigrations

func ResetMigrations()

func ValidateRegistry

func ValidateRegistry() error

Validate that registry is provided

Types

type Migration

type Migration struct {
	Version   string
	Name      string
	CreatedAt time.Time
	Up        func(*gorm.DB) error
	Down      func(*gorm.DB) error
}

func GetRegisteredMigrations

func GetRegisteredMigrations() []*Migration

type MigrationRecord

type MigrationRecord struct {
	Version   string    `gorm:"primaryKey"`
	Name      string    `gorm:"not null"`
	AppliedAt time.Time `gorm:"not null"`
}

type Migrator

type Migrator struct {
	// contains filtered or unexported fields
}

func NewMigrator

func NewMigrator(db *gorm.DB) *Migrator

func (*Migrator) Down

func (m *Migrator) Down() error

func (*Migrator) GetAppliedVersions

func (m *Migrator) GetAppliedVersions() (map[string]bool, error)

func (*Migrator) Register

func (m *Migrator) Register(migration *Migration)

func (*Migrator) Up

func (m *Migrator) Up() error

type ModelRegistry

type ModelRegistry interface {
	GetModels() map[string]interface{}
}

ModelRegistry - users must implement this

var GlobalModelRegistry ModelRegistry

Global registry - users set this in their main.go

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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