-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yaml
69 lines (60 loc) · 2.45 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
# https://taskfile.dev
version: '3'
dotenv: [".env"]
tasks:
###################################################
# App
###################################################
runapp:
desc: Start the go app
cmds:
- cd ./server && go run main.go
###################################################
# MySQL + Redis - Docker
###################################################
runsql:
desc: Start/Restart a MySQL container in Docker
cmds:
- docker rm -f session-mysql || true # Delete container if exists
- docker run --name session-mysql -e MYSQL_ROOT_PASSWORD="$MYSQL_PASS" -e MYSQL_DATABASE=default_db -p 3306:3306 --detach mysql:8.0
sqlcli:
desc: Open a CLI into MYSQL inside Docker
cmds:
- docker exec -it session-mysql mysql -p
runredis:
desc: Start / Restart a Redis container in Docker
cmds:
- docker rm -f session-redis || true # Delete container if exists
- docker run --name session-redis -d -p 6379:6379 -e REDIS_PASSWORD="$REDIS_PASSWORD" redis:7.0-alpine
rediscli:
desc: Open a CLI into Redis inside Docker
cmds:
- docker exec -it session-redis redis-cli
stopcontainers:
desc: Stop MySQL and Redis containers
cmds:
- docker stop session-mysql
- docker stop session-redis
###################################################
# DB Migrations
###################################################
newmigration:
desc: Create a new migration file. Example - task newmigration -- add_new_cols
cmds:
- goose -dir ./database/migrations create {{.CLI_ARGS}} sql
newseed:
desc: Create a new seed file. Example - task newseed -- add_dummy_rows
cmds:
- goose -dir ./database/seeds create {{.CLI_ARGS}} sql
migrate:
desc: Run all migration files (up)
cmds:
- goose -dir ./database/migrations -table _migrations mysql "$MYSQL_USER:$MYSQL_PASS@tcp(localhost:3306)/default_db?parseTime=True" up
seed:
desc: Run all seed files (up)
cmds:
- goose -dir ./database/seeds -table _seeds mysql "$MYSQL_USER:$MYSQL_PASS@tcp(localhost:3306)/default_db?parseTime=True" up
seeddown:
desc: Run all seed files (down)
cmds:
- goose -dir ./database/seeds -table _seeds mysql "$MYSQL_USER:$MYSQL_PASS@tcp(localhost:3306)/default_db?parseTime=True" down