TTime/backend/Makefile

54 lines
884 B
Makefile
Raw Normal View History

2024-02-12 12:40:49 +01:00
# Go parameters
GOCMD = go
GOBUILD = $(GOCMD) build
GOCLEAN = $(GOCMD) clean
GOTEST = $(GOCMD) test
GOGET = $(GOCMD) get
# SQLite database filename
DB_FILE = db.sqlite3
# Directory containing migration SQL scripts
MIGRATIONS_DIR = migrations
# Build target
build:
$(GOBUILD) -o bin/server cmd/*.go
# Run target
run: build
./bin/server
# Clean target
clean:
$(GOCLEAN)
2024-02-12 13:11:25 +01:00
rm -rf bin
2024-02-12 12:40:49 +01:00
rm -f db.sqlite3
# Test target
test:
$(GOTEST) ./...
# Get dependencies target
deps:
$(GOGET) -v ./...
# Update dependencies target
update:
$(GOGET) -u -v ./...
$(GOCMD) mod tidy
# Migration target
migrate:
@echo "Migrating database $(DB_FILE) using SQL scripts in $(MIGRATIONS_DIR)"
@for file in $(wildcard $(MIGRATIONS_DIR)/*.sql); do \
echo "Applying migration: $$file"; \
sqlite3 $(DB_FILE) < $$file; \
done
2024-02-28 10:34:51 +01:00
# Format
fmt:
$(GOCMD) fmt ./...
2024-02-12 12:40:49 +01:00
# Default target
default: build