You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			32 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Makefile
		
	
			
		
		
	
	
			32 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Makefile
		
	
SQL_DATABASE?=./ratchet.db
 | 
						|
 | 
						|
test:
 | 
						|
	go test -v ./...
 | 
						|
PHONEY: test
 | 
						|
 | 
						|
serve:
 | 
						|
	go run ./cmd/ratchetd/main.go
 | 
						|
PHONEY: serve
 | 
						|
 | 
						|
 | 
						|
# SQLite Commands
 | 
						|
 | 
						|
sql-cli:
 | 
						|
	sqlite3 $(SQL_DATABASE) -cmd ".headers on" -cmd ".mode box" -cmd ".tables"
 | 
						|
 | 
						|
init-db: run-migrate
 | 
						|
	sqlite3 $(SQL_DATABASE) "PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL;"
 | 
						|
 | 
						|
seed-db:
 | 
						|
	sqlite3 $(SQL_DATABASE) "INSERT INTO snippets (title, content, expires_at) VALUES ('placeholder', 'placeholder content', datetime('now', '+6 months'));"
 | 
						|
 | 
						|
run-migrate:
 | 
						|
	migrate -database sqlite3://$(SQL_DATABASE) -path ./migrations up
 | 
						|
 | 
						|
# Checks system dependencies needed to run the local dev environment
 | 
						|
check-system-deps:
 | 
						|
	@echo "Checking system dependencies..."
 | 
						|
	@command -v air > /dev/null || (echo "Missing air command. go install github.com/air-verse/air@latest"; exit 1)
 | 
						|
	@command -v sqlite3 > /dev/null || (echo "Missing sqlite3 command. brew install sqlite"; exit 1)
 | 
						|
	@command -v migrate > /dev/null || (echo "Missing migrate command. go install -tags 'sqlite3' github.com/golang-migrate/migrate/v4/cmd/migrate@latest"; exit 1)
 | 
						|
	@echo "System dependencies fulfilled 👍"
 |