gen_sqlboiler: fix incorrect database path for non-default sqlite location (#603)

* the generator should use the same path as the database/drivers/sqlite3
* remove unused data directory
* generate sqlboiler.json for model generation
* ignore target folder
This commit is contained in:
Rauno Ots
2020-12-02 00:11:10 +01:00
committed by GitHub
parent ba4ac4f3d6
commit 45d0973137
3 changed files with 21 additions and 13 deletions

View File

@@ -7,6 +7,7 @@ GCTPROFILERLISTENPORT=8085
CRON = $(TRAVIS_EVENT_TYPE)
DRIVER ?= psql
RACE_FLAG := $(if $(NO_RACE_TEST),,-race)
CONFIG_FLAG = $(if $(CONFIG),-config $(CONFIG),)
.PHONY: get linter check test build install update_deps
@@ -52,9 +53,16 @@ profile_heap:
profile_cpu:
go tool pprof -http "localhost:$(GCTPROFILERLISTENPORT)" 'http://localhost:$(GCTLISTENPORT)/debug/pprof/profile'
gen_db_models:
.PHONY: gen_db_models
gen_db_models: target/sqlboiler.json
ifeq ($(DRIVER), psql)
sqlboiler -o database/models/postgres -p postgres --no-auto-timestamps --wipe $(DRIVER)
sqlboiler -c $< -o database/models/postgres -p postgres --no-auto-timestamps --wipe $(DRIVER)
else ifeq ($(DRIVER), sqlite3)
sqlboiler -c $< -o database/models/sqlite3 -p sqlite3 --no-auto-timestamps --wipe $(DRIVER)
else
sqlboiler -o database/models/sqlite3 -p sqlite3 --no-auto-timestamps --wipe $(DRIVER)
$(error Driver '$(DRIVER)' not supported)
endif
target/sqlboiler.json:
mkdir -p $(@D)
go run ./cmd/gen_sqlboiler_config/main.go $(CONFIG_FLAG) -outdir $(@D)