migrations

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2018 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Libs = []templates.Library{
	{Name: "{{.Repo}}/migrations"},
}
View Source
var Models = map[string]string{}
View Source
var TemplateRunFunction = ""
View Source
var TemplateSetter = `` /* 128-byte string literal not displayed */
View Source
var TemplateSetterFunction = `` /* 145-byte string literal not displayed */
View Source
var Templates = map[string]string{
	"migrations/migrations.go": `package migrations

import (
	"github.com/go-pg/migrations"
	"github.com/go-pg/pg"
	"go.uber.org/zap"
)

func Init(db *pg.DB, logger *zap.Logger) {
	migrations.SetTableName("_{{.Name}}_migrations")

	oldVersion, newVersion, err := migrations.Run(db, "up")

	if err != nil {
		logger.Fatal("Error on run migration", zap.Error(err))
	}

	if newVersion != oldVersion {
		logger.Info("Migrations: migrated", zap.Int64("old", oldVersion), zap.Int64("new", newVersion))
	} else {
		logger.Info("Migrations: version", zap.Int64("current", oldVersion))
	}
}
`,
	"migrations/01_init.go": `package migrations

import (
	"fmt"
	"github.com/go-pg/migrations"
)

func init() {
	migrations.Register(func(db migrations.DB) error {
		fmt.Println("init migration...")

		_, err := db.Exec("SELECT 1")

		return err
	}, func(db migrations.DB) error {
		_, err := db.Exec("SELECT 1")

		return err
	})
}
`,
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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