From 9aac8ab8b2bb85fda8389355e752cf3238f78bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Eduardo=20Jer=C3=A9z=20Gir=C3=B3n?= Date: Thu, 5 Sep 2024 23:13:54 -0600 Subject: [PATCH] Move goose command to taskfile entirely --- cmd/goose/main.go | 37 ------------------------------------- taskfile.yaml | 7 ++++++- 2 files changed, 6 insertions(+), 38 deletions(-) delete mode 100644 cmd/goose/main.go diff --git a/cmd/goose/main.go b/cmd/goose/main.go deleted file mode 100644 index 63c576f..0000000 --- a/cmd/goose/main.go +++ /dev/null @@ -1,37 +0,0 @@ -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(true) - - cmd := fmt.Sprintf( - "goose -dir %s postgres \"%s\" %s", - migrationsFolder, - *env.PBW_POSTGRES_CONN_STRING, - gooseCmd, - ) - - fmt.Println(cmd) -} diff --git a/taskfile.yaml b/taskfile.yaml index f7acf83..1f684e8 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -60,7 +60,12 @@ tasks: - task serve goose: - cmd: eval $(go run ./cmd/goose/. {{.CLI_ARGS}}) + silent: true + cmd: > + goose + -dir ./internal/database/migrations + postgres "{{.PBW_POSTGRES_CONN_STRING}}" + {{.CLI_ARGS}} gen-db: cmd: sqlc generate