-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yaml
68 lines (58 loc) · 1.92 KB
/
Taskfile.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
version: '3'
dotenv: ['.env']
vars:
sql_migrate_version: v1.5.2
sql_c_version: v1.19.1
env:
DOCKER_BUILDKIT: "1"
tasks:
default:
- go run .
single-test:
cmds:
- go test --count=1 -v {{.CLI_ARGS}}
# task single-test -- ./emailing -run TestSendEmail
# - go test --count=1 -v ./... -run {{.CLI_ARGS}}
# task single-test -- TestName
install-deps:
cmds:
- go install github.com/rubenv/sql-migrate/...@{{.sql_migrate_version}}
- go install github.com/kyleconroy/sqlc/cmd/sqlc@{{.sql_c_version}}
sql-up:
preconditions:
- msg: set env CRDB_DSN and SQL_ENV to local,staging,prod,development
sh: echo $SQL_ENV | grep .
cmds:
- sql-migrate up --env=$SQL_ENV
- task: sql-status
sql-down:
preconditions:
- msg: set env CRDB_DSN and SQL_ENV to local,staging,prod,development
sh: echo $SQL_ENV | grep .
cmds:
- sql-migrate down --env=$SQL_ENV
- task: sql-status
sql-status:
preconditions:
- msg: set env CRDB_DSN and SQL_ENV to local,staging,prod,development
sh: echo $SQL_ENV | grep .
cmds:
- sql-migrate status --env=$SQL_ENV
sql-gen:
desc: generate typed methods for SQL execution
silent: true
cmds:
# concatenates all migrations but drops the "migrate down" parts
- ls migrations/*.sql migrations/*.sql.later | xargs -n1 sed '/^-- +migrate Down/ ,$d' > schema.sql
# There are a bunch of SQL features that don't matter for SQLC but break their parser
- sed -i -e 's/ON UPDATE NOW[(][)]//g' schema.sql
- sed -i -e 's/CREATE DATABASE.*//g' schema.sql
- sed -i -e 's/CREATE INDEX.*//g' schema.sql
- sed -i -e 's/CREATE USER.*//g' schema.sql
- sed -i -e 's/GRANT.*//g' schema.sql
- sed -i -e 's/DESC//g' schema.sql
- sed -i -e 's/USING HASH.*//g' schema.sql
- rm -f query/*.sql.go
- sqlc generate
- rm schema.sql*
- echo done