-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
43 lines (31 loc) · 1.09 KB
/
Makefile
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
GOOSE := go run github.com/pressly/goose/v3/cmd/goose@v3.22.0
DB_PATH := ./zettel.db
TMP_DB_PATH := /tmp/zet/zettel.db
MIGRATIONS_DIR := ./migrations
.PHONY: build build-tmp watch new up down status schema test
build:
go build -tags "fts5" -o zet ./cmd/zet
$(GOOSE) -dir $(MIGRATIONS_DIR) sqlite3 $(DB_PATH) up
install:
sudo install -m 755 ./zet ~/.local/bin/zet
build-tmp:
TEST=true go test -tags "fts5" ./...
go build -tags "fts5" -o zet ./cmd/zet
$(GOOSE) -dir $(MIGRATIONS_DIR) sqlite3 $(TMP_DB_PATH) up
watch:
find . -name '*.go' | entr -cs 'TEST=true go test -tags "fts5" ./... && go build -tags "fts5" -o zet ./cmd/zet'
new:
@read -p "Enter the name of the new migration: " name; \
$(GOOSE) -dir $(MIGRATIONS_DIR) sqlite3 $(DB_PATH) create $$name sql
up:
$(GOOSE) -dir $(MIGRATIONS_DIR) sqlite3 $(DB_PATH) up-by-one
down:
$(GOOSE) -dir $(MIGRATIONS_DIR) sqlite3 $(DB_PATH) down
redo:
$(GOOSE) -dir $(MIGRATIONS_DIR) sqlite3 $(DB_PATH) redo
status:
$(GOOSE) -dir $(MIGRATIONS_DIR) sqlite3 $(DB_PATH) status
schema:
sqlite3 $(DB_PATH) .schema
test:
TEST=true go test -tags "fts5" ./...