Version: v0.0.0-...-aab71bc Latest Latest

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

Go to latest
Published: Sep 12, 2021 License: MIT Imports: 13 Imported by: 0




This section is empty.


View Source
var MigrationTargetFolder string

MigrationTargetFolder is the migration folder target.


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 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
	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
t or T : Toggle theme light dark auto
y or Y : Canonical URL