env_migrate

package module
v0.0.0-...-aca0a3f Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: MIT Imports: 7 Imported by: 0

README

Env migrate

Use github.com/rubenv/sql-migrate and env, auto run migrate.

启用 sql-migrate


func main(){
  env_migrate.Auto(db) // db is database/sql *sql.DB
}

启动服务/迁移数据库

migrate 会读取 migrations/*.sql 进行迁移

启动并执行所有迁移

up_migrate=all go run main.go

执行回滚,1 次, down_migrate 结束会自动退出

down_migrate=1 go run main.go

执行跳过,2 次, skip_migrate 结束会自动退出

skip_migrate=2 go run main.go

使用其他 migrations 路径

up_migrate=all dir_migrate=sql/migrations go run main.go

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BaseRootDir = ""

Functions

func Auto

func Auto(db *sql.DB, dbName string)

func DownMigration

func DownMigration(db *sql.DB, max int, dbName string)

func SkipMigration

func SkipMigration(db *sql.DB, max int, dbName string)

func UpMigration

func UpMigration(db *sql.DB, max int, dbName string)

Types

This section is empty.

Jump to

Keyboard shortcuts

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