CREATE TABLE calls in hot
paths.
Schema, Migration, Apply
Schema is the desired database shape: tables, columns, indexes, constraints, and views. Migration is a versioned change from one schema state to another. The apply API makes the database ready at runtime:Manifest Permissions
Apps that create or alter schema needddl permission for the same database
path they use at runtime.
tc.sql shortcut, the database name is default.
default when the app uses that shortcut.
What To Avoid
Do not run cold DDL in hot user paths. RuntimeCREATE TABLE or ALTER TABLE
can fail behind proxies, race under concurrent requests, or produce confusing
authorization errors if the manifest does not include ddl.
Do not copy app-specific ensureSchema helpers between apps. Use migrations so
locking, idempotency, action signing, and error shape are handled consistently.
Do not treat materialized indexes as canonical data. If a table mirrors KV,
capabilities, or another source of truth, document it as rebuildable.
Agent Notes
When reviewing a TinyCloud app:- Check that schema-changing SQL has
ddlin the manifest. - Check that the manifest database path matches the SDK database name.
- Prefer
migrations.apply(...)over customensureSchemacode. - Treat missing cache tables as setup drift or cache misses, not data loss.
- Surface migration errors visibly instead of turning them into empty states.