goMigration

module
v0.0.0-...-38c9441 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2022 License: Apache-2.0

README

goMigration

基于 Golang 的 MySQL 数据库迁移工具,目前仍在开发中,有兴趣的小伙伴可以联系我一起~

食用方法
go get https://github.com/DGuang21/goMigration

手动将其安装

可通过 gom gen create_c_user_table 方法生成如下文件,在闭包函数中自由修改你所需的字段及方法

type migrationCreatePowerTableInterface struct {}

func init() {
	migration.RegisterMigration(&migrationCreatePowerTableInterface{},"20211004202802_c_up_date")
}

func (m *migrationCreatePowerTableInterface) Up() {
	migration.Create("asd",func(table *migration.MigrationTable) {
		table.String("1").NullTable(false).Comment("s")
		table.Timestamps().NullTable(false).Comment("s")
		table.Charset("utf8")
		table.Engine("InnoDB")
		table.Done()
	})
}

func (m *migrationCreatePowerTableInterface) Down() {
	migration.DropIfExists("kos")
}

而后执行gom run migrationgo run demo/main.go 进行数据库或表迁移

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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