Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Env []templates.Environment
View Source
var Libs = []templates.Library{
{Name: "{{.Repo}}/migrations"},
}
View Source
var Models = map[string]string{}
View Source
var Props []templates.Property
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.
Click to show internal directories.
Click to hide internal directories.