Skip to content

Commit

Permalink
modify template for go migration
Browse files Browse the repository at this point in the history
  • Loading branch information
ori-shalom committed May 8, 2023
1 parent 273ded4 commit db6e311
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions create.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,21 @@ SELECT 'down SQL query';
var goSQLMigrationTemplate = template.Must(template.New("goose.go-migration").Parse(`package migrations
import (
"context"
"database/sql"
"github.com/pressly/goose/v3"
)
func init() {
goose.AddMigration(up{{.CamelName}}, down{{.CamelName}})
goose.AddMigrationContext(up{{.CamelName}}, down{{.CamelName}})
}
func up{{.CamelName}}(tx *sql.Tx) error {
func up{{.CamelName}}(ctx context.Context, tx *sql.Tx) error {
// This code is executed when the migration is applied.
return nil
}
func down{{.CamelName}}(tx *sql.Tx) error {
func down{{.CamelName}}(ctx context.Context, tx *sql.Tx) error {
// This code is executed when the migration is rolled back.
return nil
}
Expand Down

0 comments on commit db6e311

Please sign in to comment.