-
Notifications
You must be signed in to change notification settings - Fork 0
/
templates.go
45 lines (32 loc) · 969 Bytes
/
templates.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package cmds
import "text/template"
var sqlMigrationTemplate = template.Must(template.New("goose.sql-migration").Parse(`
-- Documentation can be found here: https://pressly.github.io/goose
-- The -- +goose NO TRANSACTION directive may be added to the top of the file to run statements
-- outside a transaction.
-- +goose Up
-- +goose StatementBegin
SELECT 'up SQL query';
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
SELECT 'down SQL query';
-- +goose StatementEnd
`))
var goMigrationTemplate = template.Must(template.New("goose.go-migration").Parse(`package migrations
import (
"database/sql"
"github.com/pressly/goose/v3"
)
func init() {
goose.AddMigration(up{{.CamelName}}, down{{.CamelName}})
}
func up{{.CamelName}}(tx *sql.Tx) error {
// This code is executed when the migration is applied.
return nil
}
func down{{.CamelName}}(tx *sql.Tx) error {
// This code is executed when the migration is rolled back.
return nil
}
`))