451da3d26d
Support for service accounts with static credentials * feature complete * tests and docs * lint fix
46 lines
1.3 KiB
YAML
46 lines
1.3 KiB
YAML
---
|
|
# 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
|
|
- 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
|