Generate and create the D1 schema (paid)
nc_schemaIdempotent
Generates numbered D1 migration SQL files and a Drizzle schema from the agreed plan (nc_plan), and writes them to the customer's R2 under nc//schema/. With apply: true it creates the D1 database in the customer's account and runs the migrations. Safe to repeat: every statement is idempotent. Run nc_plan first and agree its skip list with the owner. Paid: needs a pass for the app, or the free trial for plans up to 1,000 records.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"job_id": "<job_id>"
},
"name": "nc_schema"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apply | No | Create the database and run the migrations. Default false: only generate the files. | |
| job_id | Yes | ||
| upgrade | No | Set true to pay the difference to the next pass that fits, only when the app is past its pass's (or free trial's) record or file limit. | |
| go_ahead | No | Set true only when a charge applies, once the owner has seen the estimate and agreed to it. Not needed under the free trial or a pass that already covers the app. Needed again after a pass has expired. | |
| r2_bucket | No | An R2 bucket in that account, for staging and schema files. | |
| cf_api_token | No | A Cloudflare API token with D1 edit permission on that account. Sealed in the job, deleted when it ends. Prefer nc_connect with job_id: the owner types tokens on a secure page. Only pass it here if nc_connect is not available. | |
| cf_account_id | No | The customer's Cloudflare account id. | |
| database_name | No | Name of the D1 database to create or reuse, for example nc-sharehousehub-staging. | |
| max_statements | No | Statements to run per call when applying. Default 100. | |
| r2_access_key_id | No | Access key id of an R2 API token that can read and write that bucket. Prefer nc_connect with job_id: the owner types tokens on a secure page. Only pass it here if nc_connect is not available. | |
| r2_secret_access_key | No | Its secret. Sealed in the job, deleted when it ends. Prefer nc_connect with job_id: the owner types tokens on a secure page. Only pass it here if nc_connect is not available. |