mirror of
https://github.com/eduardolat/pgbackweb.git
synced 2026-01-27 15:08:34 -06:00
Add goose command for database migrations
This commit is contained in:
37
cmd/goose/main.go
Normal file
37
cmd/goose/main.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/eduardolat/pgbackweb/internal/config"
|
||||
)
|
||||
|
||||
const migrationsFolder string = "./internal/database/migrations"
|
||||
|
||||
func main() {
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Println("goose command is required")
|
||||
fmt.Println("example: task goose -- up")
|
||||
return
|
||||
}
|
||||
|
||||
gooseCmd := ""
|
||||
for i, arg := range os.Args {
|
||||
if i == 0 {
|
||||
continue
|
||||
}
|
||||
gooseCmd += arg + " "
|
||||
}
|
||||
|
||||
env := config.GetEnv()
|
||||
|
||||
cmd := fmt.Sprintf(
|
||||
"goose -dir %s postgres \"%s\" %s",
|
||||
migrationsFolder,
|
||||
*env.PBW_POSTGRES_CONN_STRING,
|
||||
gooseCmd,
|
||||
)
|
||||
|
||||
fmt.Println(cmd)
|
||||
}
|
||||
@@ -30,6 +30,9 @@ tasks:
|
||||
- task build
|
||||
- task serve
|
||||
|
||||
goose:
|
||||
cmd: eval $(go run ./cmd/goose/. {{.CLI_ARGS}})
|
||||
|
||||
gen-css:
|
||||
cmd: >
|
||||
npm run tailwindcss --
|
||||
|
||||
Reference in New Issue
Block a user