Schema Updates

Always send the full schema. MoonDB diffs it against the current version and generates migrations automatically.

Non-destructive changes

Applied immediately, no confirmation needed:

Destructive changes

Returns a preview first. Add "confirm_destructive": true to apply:

PUT /p/{id}/v1/schema
{
  "tables": { ... },
  "confirm_destructive": true
}

Useful endpoints

GET  /p/{id}/v1/schema             # current schema + version
POST /p/{id}/v1/schema/validate     # dry-run without applying
GET  /p/{id}/v1/schema/history     # version history (admin key)
POST /p/{id}/v1/schema/seed        # bulk-load rows with @table.index cross-refs
GET  /p/{id}/v1/openapi.json       # OpenAPI 3.0.3 spec, auto-generated
GET  /p/{id}/v1/llm-context        # agent prompt — re-fetch after every schema change

Seed example

Use @<table>.<index> to reference rows inserted earlier in the same request:

POST /p/{id}/v1/schema/seed
{
  "users":  [{ "email": "a@x.io", "password": "secret" }],
  "habits": [{ "user_id": "@users.0", "name": "Run" }]
}