server/src/defs/db_schema.ts, generate migrations with the CLI, and query the database from the runtime SDK.
Define your schema
Add app tables toserver/src/defs/db_schema.ts:
server/src/defs/db_schema.ts
server/src/defs/db_relations.ts.
Generate and apply migrations
After editingdb_schema.ts, run:
Query data
Use the runtime SDK inside route handlers:server/src/index.ts
Update and delete data
server/src/index.ts
Run ad-hoc SQL
For inspection or one-off data changes, use:Constraints
Transactions are not available. Usedb.batch([...]) for atomic multi-step operations, and see platform limits whenever you are working near database or bundle constraints.
See also
db reference
Complete API for selects, inserts, updates, deletes, relational queries, and batching.
Declarative workflow
How schema files, generated types, and migrations stay in sync.