File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 11COMPOSE ?= docker compose -f docker-compose.dev.yml
22
3- .PHONY : dev dev-detach down shell console test imap logs db-migrate db-reset psql sim-email-once sim-email-stream
3+ .PHONY : dev dev-detach down shell console test imap logs db-migrate db-reset db-import stats psql sim-email-once sim-email-stream
44
55dev : # # Start dev stack (foreground)
66 $(COMPOSE ) up --build
@@ -30,6 +30,18 @@ db-migrate: ## Run db:migrate
3030db-reset : # # Drop and prepare (create/migrate)
3131 $(COMPOSE ) run --rm web bin/rails db:drop && bin/rails db:prepare
3232
33+ db-import : # # Drop dev DB and import a public dump (env: DUMP=/path/to/public-YYYY-MM.sql.gz)
34+ @if [ -z " $( DUMP) " ]; then echo " Set DUMP=/path/to/public-YYYY-MM.sql.gz" ; exit 1; fi
35+ $(COMPOSE ) exec -T db bash -lc ' psql -U $${POSTGRES_USER:-hackorum} -d postgres -c "DROP DATABASE IF EXISTS $${POSTGRES_DB:-hackorum_development};" -c "CREATE DATABASE $${POSTGRES_DB:-hackorum_development};"'
36+ @if echo " $( DUMP) " | grep -qE ' \.gz$$' ; then \
37+ gzip -cd " $( DUMP) " | $(COMPOSE ) exec -T db bash -lc ' psql -U $${POSTGRES_USER:-hackorum} -d $${POSTGRES_DB:-hackorum_development}' ; \
38+ else \
39+ cat " $( DUMP) " | $(COMPOSE ) exec -T db bash -lc ' psql -U $${POSTGRES_USER:-hackorum} -d $${POSTGRES_DB:-hackorum_development}' ; \
40+ fi
41+
42+ stats : # # Rebuild stats (env: GRANULARITY=all|daily|weekly|monthly)
43+ $(COMPOSE ) exec web bundle exec ruby script/build_stats.rb $$ {GRANULARITY:-all}
44+
3345psql : # # Open psql against the dev DB
3446 COMPOSE_PROFILES=tools $(COMPOSE ) run --rm psql
3547
Original file line number Diff line number Diff line change @@ -23,14 +23,18 @@ Useful commands:
2323* Rails console: ` docker compose -f docker-compose.dev.yml exec web bin/rails console `
2424* Migrations/seeds: ` docker compose -f docker-compose.dev.yml exec web bin/rails db:prepare `
2525* Tests: ` docker compose -f docker-compose.dev.yml exec web bundle exec rspec `
26+ * Import a public DB dump: ` make db-import DUMP=/path/to/public-YYYY-MM.sql.gz `
2627
2728Makefile shortcuts:
2829* ` make dev ` / ` make dev-detach ` / ` make down `
2930* ` make shell ` / ` make console ` / ` make logs `
3031* ` make test `
3132* ` make db-migrate ` / ` make db-reset `
33+ * ` make db-import `
3234* ` make psql `
3335
36+ Public database dumps (schema + public data) are published at https://dumps.hackorum.dev/
37+
3438### Incoming email simulator
3539
3640There are two helper scripts ` script/simulate_email_once.rb ` and ` simulate_email_stream.rb ` that simulate incoming emails.
You can’t perform that action at this time.
0 commit comments