migration

package
v0.0.0-...-1ae172a Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const FirstVersion = ""

Variables

View Source
var Migrations []*Migration

Functions

func GetMigrationsMap

func GetMigrationsMap() (map[string]*Migration, error)

GetMigrationsMap 获取所有迁移版本的字典,key是当前版本指向的前一个版本 如果有两个指向一样的父版本号,则返回报错,保证不会分叉

func Register

func Register(m *Migration)

Register 注册迁移函数

Types

type MigrateFunc

type MigrateFunc func(db *gorm.DB) error

MigrateFunc 迁移函数

type Migration

type Migration struct {
	// 当前迁移的版本号
	Version string
	// 上一个版本号
	ParentVersion string
	// 真正的迁移方法
	MigrateFunc MigrateFunc
	// 迁移说明
	Description string
}

Jump to

Keyboard shortcuts

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