phase 0.3
This commit is contained in:
commit
4a94bfc4e7
52 changed files with 11653 additions and 0 deletions
71
sqlc_generate.bat
Normal file
71
sqlc_generate.bat
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
@echo off
|
||||
setlocal
|
||||
|
||||
:: ============================================================
|
||||
:: Skyrama TUI - sqlc code generator
|
||||
:: Run this from the skyrama-tui\ root folder whenever you
|
||||
:: change sql\schema.sql or sql\queries.sql.
|
||||
::
|
||||
:: Output goes to: internal\db\ (db.go, models.go, query.sql.go)
|
||||
:: ============================================================
|
||||
|
||||
cd /d "%~dp0"
|
||||
|
||||
:: ── 1. Make sure sqlc is installed ───────────────────────────
|
||||
where sqlc >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo.
|
||||
echo [*] sqlc not found. Installing via go install...
|
||||
echo ^(requires Go 1.21+ and an internet connection^)
|
||||
echo.
|
||||
go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
|
||||
if errorlevel 1 (
|
||||
echo.
|
||||
echo [ERROR] Could not install sqlc automatically.
|
||||
echo.
|
||||
echo Manual options:
|
||||
echo A^) go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
|
||||
echo B^) Download the Windows binary from:
|
||||
echo https://github.com/sqlc-dev/sqlc/releases/latest
|
||||
echo and place sqlc.exe somewhere on your PATH.
|
||||
echo.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo [OK] sqlc installed.
|
||||
echo.
|
||||
)
|
||||
|
||||
:: ── 2. Show the sqlc version we're using ─────────────────────
|
||||
echo [*] Using:
|
||||
sqlc version
|
||||
echo.
|
||||
|
||||
:: ── 3. Run the generator ─────────────────────────────────────
|
||||
echo [*] Generating Go code from sql\schema.sql + sql\queries.sql ...
|
||||
sqlc generate
|
||||
if errorlevel 1 (
|
||||
echo.
|
||||
echo [ERROR] sqlc generate failed. Fix the errors above, then re-run.
|
||||
echo.
|
||||
echo Common causes:
|
||||
echo - SQL syntax error in sql\queries.sql
|
||||
echo - Query references a column that does not exist in sql\schema.sql
|
||||
echo - Missing -- name: QueryName :one/many/exec annotation
|
||||
echo.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo [OK] Done! Generated files are in internal\db\
|
||||
echo db.go - DB and Querier interface
|
||||
echo models.go - Struct types for every table
|
||||
echo query.sql.go - One function per named query
|
||||
echo.
|
||||
echo Rebuild the app now:
|
||||
echo run.bat
|
||||
echo.
|
||||
pause >nul
|
||||
|
||||
endlocal
|
||||
Loading…
Add table
Add a link
Reference in a new issue