Database sample data, make target and go code
This commit is contained in:
parent
47b60038b4
commit
c31f145c35
4 changed files with 64 additions and 0 deletions
|
@ -10,6 +10,7 @@ DB_FILE = db.sqlite3
|
|||
|
||||
# Directory containing migration SQL scripts
|
||||
MIGRATIONS_DIR = internal/database/migrations
|
||||
SAMPLE_DATA_DIR = internal/database/sample_data
|
||||
|
||||
# Build target
|
||||
build:
|
||||
|
@ -54,6 +55,14 @@ migrate:
|
|||
sqlite3 $(DB_FILE) < $$file; \
|
||||
done
|
||||
|
||||
sampledata:
|
||||
@echo "If this ever fails, run make clean and try again"
|
||||
@echo "Migrating database $(DB_FILE) using SQL scripts in $(SAMPLE_DATA_DIR)"
|
||||
@for file in $(wildcard $(SAMPLE_DATA_DIR)/*.sql); do \
|
||||
echo "Applying migration: $$file"; \
|
||||
sqlite3 $(DB_FILE) < $$file; \
|
||||
done
|
||||
|
||||
# Target added primarily for CI/CD to ensure that the database is created before running tests
|
||||
db.sqlite3:
|
||||
make migrate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue