Files
query-orchestration/scripts/database.yml
T

46 lines
1.3 KiB
YAML
Raw Normal View History

2025-01-10 11:12:03 +00:00
---
# https://taskfile.dev
version: "3"
vars:
MIGRATIONS: "internal/database/migrations"
QUERIES: "internal/database/queries/"
CONFIG_FILE: "sqlc.yml"
includes:
compose:
dir: ".."
taskfile: local-deployments.yml
internal: true
tasks:
generate:
desc: "Recreate the generate DB, apply migrations, and run sqlc generate"
run: once
cmds:
- task: compose:up:generate
2025-05-08 16:04:45 +00:00
- psql -p ${PGPORT_GENERATE} postgres -c "DROP DATABASE if exists ${PGDATABASE};"
- psql -p ${PGPORT_GENERATE} postgres -c "CREATE DATABASE ${PGDATABASE};"
- migrate -path {{.MIGRATIONS}} -database {{.DB_URI_GENERATE}} up
- sqlc generate --file {{.CONFIG_FILE}}
lint:
desc: "Validate SQL queries with sqlc vet (and sqlcheck on migrations)"
cmds:
- task: compose:up:generate
- sqlc vet --file {{.CONFIG_FILE}}
- |
exit 0
for file in {{.MIGRATIONS}}/*.sql; do
if [[ -f "$file" ]]; then
sqlcheck -c -f $file -r 3 # move to 1
fi
done
mig:create:
desc: "Interactively scaffold a new SQL migration in internal/database/migrations"
cmds:
- |
read -p "Migration Name: " name
test -z "$name" && echo "Error: Name is required." && exit 1
migrate create -ext sql -dir {{.MIGRATIONS}} $name