Developer reference
Generated database types
Keep typed database structure aligned with verified schema while exposing safe service contracts.
src/lib/types/database.ts describes the database shape used by typed clients. It helps catch structural incompatibility; it does not authorize access or validate financial meaning.
When the schema changes
- Apply the approved forward migration to the authorized target.
- Verify the table or RPC’s actual runtime shape and permissions.
- Update generated types from that shape.
- Update service callers and API response contracts together.
- Run the affected types and behavior checks.
Do not make a type change stand in for a database migration.
Database types versus API types
A database row can contain server-only or unrelated fields. A financial response should expose owned data with the currency, date and evidence needed by its consumer. Do not send an entire row simply because its generated type is easy to import.
RPC contracts
Read the actual function signature and return shape before changing a caller. Optional fields and financial precision affect domain behavior; satisfying TypeScript is not sufficient evidence of a correct command.
Common mistake
A cast can silence a mismatch while leaving the deployed schema unchanged. Diagnose version drift instead of using broad any or forced casts to hide it.
See financial functions, migration discipline and service boundaries.