Version: v0.0.0-...-404c35a Latest Latest

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

Go to latest
Published: May 26, 2023 License: MIT Imports: 13 Imported by: 0




This section is empty.


View Source
var (
	ErrMigrationCanceled   = errors.New("rollback migration canceled")
	ErrEmptyPurpose        = errors.New("missing purpose when creating migration")
	ErrDuplicatedMigration = errors.New("migration exists")
	ErrNoMigration         = errors.New("running with no migration")
View Source
var MigrationTargetFolder string

MigrationTargetFolder is the migration folder target.


func BuildPlugin

func BuildPlugin(fileName string) (string, error)

func CreateConnection

func CreateConnection(c GormCliConfig) (string, error)

CreateConnection - Create the migration file with template.

func CreateMigration

func CreateMigration(purpose string) (string, error)

CreateMigration - Create the migration file with template.

func DownMigration

func DownMigration(db *gorm.DB, files []os.FileInfo, step int64) error

DownMigration - Rollback migration

func NewDB

func NewDB() *gorm.DB

NewDB get gorm DB instance.

func RemovePlugin

func RemovePlugin(goFileName string) error

func UpMigrate

func UpMigrate(db *gorm.DB, files []os.FileInfo) error

UpMigrate - Run migration


type GormCliConfig

type GormCliConfig struct {
	DB struct {
		Dialects string
		Port     string
		Host     string
		User     string
		Password string
		Dbname   string
		Charset  string
		SSLMode  string
		TimeZone string
	Migration struct {
		Path string

GormCliConfig is the config for how gorm-cli connecting to DB

type GormMeta

type GormMeta struct {

	Name string `gorm:"type:varchar(255);primary_key"`

GormMeta - The meta for storing which migration has been executed.

type Migration

type Migration interface {
	Up(*gorm.DB) error
	Down(*gorm.DB) error

Migration - The main interface for migration files

Jump to

Keyboard shortcuts

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