migorm

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InfoLevel  = "INFO"
	ErrorLevel = "ERROR"
)
View Source
const DefaultMigrationsTableName = "migrations"

Variables

This section is empty.

Functions

func RegisterMigration

func RegisterMigration(migration any)

RegisterMigration Each migration file call this method in its init method

func Run

func Run(ctx context.Context, migrater Migrater)

func WithCustomMigrationsTableName

func WithCustomMigrationsTableName(customTableName string) func(tx *gorm.DB) *gorm.DB

Types

type Config

type Config struct {
	Log           Logger
	MigrationsDir string
	TableName     string
}

type Context

type Context interface {
	context.Context
	DB() *gorm.DB
	Log() Logger
}

type Logger

type Logger interface {
	Infof(template string, args ...interface{})
	Errorf(template string, args ...interface{})
}

func NewLogger

func NewLogger() Logger

type Migrater

type Migrater interface {
	Logger(ctx context.Context) Logger
	UpMigrations(ctx context.Context) error
	UpConcreteMigration(ctx context.Context, name string) error
	DownConcreteMigration(ctx context.Context, name string) error
	MakeFileMigration(ctx context.Context, name string) error
}

func NewMigrater

func NewMigrater(db *gorm.DB, cfg *Config) Migrater

type NewMigration

type NewMigration interface {
	Up(ctx Context) error
	Down(ctx Context) error
}

Jump to

Keyboard shortcuts

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