Datasette 1.0a35 Adds Create and Alter Table UI and Template Context Docs
Use the new /<database>/-/create and /<database>/<table>/-/alter JSON APIs to programmatically create and modify tables in Datasette.
Test the new create and alter table APIs in your Datasette instance, and update any custom templates to reference the documented template context variables.
Summary
Datasette 1.0a35 introduces a new Create table interface in the database actions menu, backed by the /<database>/-/create JSON API. The UI supports defining columns, primary keys, custom types, NOT NULL constraints, literal defaults, expression defaults, and single‑column foreign keys. The release also adds an Alter table action and /<database>/<table>/-/alter API for adding, renaming, reordering, dropping columns; changing types, defaults, constraints, primary keys, foreign keys; and renaming tables.
Additionally, new template context documentation lists stable variables for custom templates, generated from dataclass definitions with tests that compare the documented fields against actual contexts. These features improve schema management directly from the UI and provide a stable API for template customization. A video demo showcases the new create/alter table functionality.
Key changes
- New Create table UI with JSON API /<database>/-/create
- Supports columns, PKs, custom types, NOT NULL, defaults, expression defaults, single‑column FK
- New Alter table UI and /<database>/<table>/-/alter API for schema modifications
- Allows adding, renaming, reordering, dropping columns; changing types, defaults, constraints, PKs, FKs; renaming tables
- New template context documentation listing stable variables for custom templates
- API endpoints generate from dataclass definitions with tests
- Video demo showcases create/alter table features
- Part of Datasette 1.0a series