SRTD - Iterative SQL Template Development
Workflow
Start watch in background immediately:
srtd watch --json
Use run_in_background: true. Monitor with TaskOutput for events: templateApplied (success), templateError (check errorMessage/errorHint).
Templates
Location: supabase/migrations-templates/*.sql. Must be idempotent.
Idempotency patterns:
- Functions/Views:
CREATE OR REPLACE(useDROPonly when changing signature) - Policies:
DROP POLICY IF EXISTSthenCREATE POLICY(not replaceable) - Triggers: Drop BOTH trigger AND function first
Dependencies: -- @depends-on: other.sql at top
WIP: .wip.sql suffix → applies locally, never builds
Commands
srtd apply [--force] [--json] # Apply to local DB (use instead of watch for one-off)
srtd build [--bundle] # Generate migration FILES only (does NOT apply to DB)
srtd clear --reset # Reset state if confused
State
.buildlog.json→ commit (tracks built migrations).buildlog.local.json→ gitignored (local DB state)
微信扫一扫