mirror of https://github.com/pressly/goose.git
Update README
parent
d0b5acabe5
commit
ca9152bc76
|
@ -1,6 +1,6 @@
|
||||||
# SQL + Go migrations
|
# SQL + Go migrations
|
||||||
|
|
||||||
## Example custom goose binary with built-in Go migrations
|
## This example: Custom goose binary with built-in Go migrations
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ go build -o goose *.go
|
$ go build -o goose *.go
|
||||||
|
@ -29,14 +29,13 @@ $
|
||||||
|
|
||||||
1. Move [main.go](main.go) into your `cmd/` directory
|
1. Move [main.go](main.go) into your `cmd/` directory
|
||||||
|
|
||||||
2. Rename migration functions to `migrations` pkg
|
2. Rename package name in all `*_.go` migration files from `main` to `migrations`.
|
||||||
|
|
||||||
3. Import `migrations` package from [cmd/main.go](main.go)
|
3. Import this `migrations` package from your custom [cmd/main.go](main.go) file:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
import (
|
import (
|
||||||
|
// Invoke init() functions within migrations pkg.
|
||||||
_ "github.com/pressly/goose/example/migrations-go"
|
_ "github.com/pressly/goose/example/migrations-go"
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
This will cause all `init()` functions to be called within `migrations` pkg, thus registering the migration functions properly.
|
|
||||||
|
|
Loading…
Reference in New Issue