Skip to content

Commit 8e63058

Browse files
committed
build: add consolidated sql make target
Working on SQL migrations and queries currently requires separate sql-lint, sql-format, and sqlc invocations, and the linting steps can rewrite SQL after code generation. Add make sql to run linting, formatting, and generation in one place so local development normalizes the SQL first and only regenerates the Go files once from the final contents.
1 parent 9e88f7c commit 8e63058

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,20 @@ sql-lint-check:
286286
@$(call print, "Linting SQL files (sqlite queries).")
287287
$(SQLFLUFF) lint --config /sql/.sqlfluff --dialect sqlite $(SQL_SQLITE_QUERIES)
288288

289+
#? sql: Lint, verify, format, and regenerate SQL code for local development
290+
# First try auto-fixes. If that still fails, rerun lint in check mode so the
291+
# remaining unfixable violations are printed before aborting the workflow.
292+
# On success, verify the final SQL is clean before formatting and regeneration.
293+
sql:
294+
@if ! $(MAKE) --no-print-directory --silent sql-lint; then \
295+
$(MAKE) --no-print-directory --silent sql-lint-check; \
296+
exit 1; \
297+
fi
298+
@$(MAKE) --no-print-directory --silent sql-lint-check
299+
@$(MAKE) --no-print-directory --silent sql-format
300+
@$(MAKE) --no-print-directory --silent sqlc
301+
302+
289303
.PHONY: all \
290304
default \
291305
build \
@@ -303,6 +317,7 @@ sql-lint-check:
303317
tidy-module \
304318
tidy-module-check \
305319
sql-parse \
320+
sql \
306321
sqlc \
307322
sqlc-check \
308323
sql-format \

0 commit comments

Comments
 (0)