CLI databases

Manage the current Site database and keep schema changes in numbered SQL files under the project-root migrations/ directory.

Create a database

interfold db create --site <site-id>

Query a database

Forward generic D1 SQL with a write-authorized API key. Queries can read or change data and schema, so use placeholders for values and review writes carefully:

interfold db query --site <site-id> 'SELECT id, name FROM users WHERE active = ?' --params '[true]'
interfold db query --site <site-id> 'UPDATE users SET active = ? WHERE id = ?' --params '[false, 42]'

The command prints the D1-style response envelope. It accepts one SQL string and an optional JSON parameter array; D1 evaluates SQL errors. This is a write-capability command even for a SELECT statement.

Create and inspect migrations

interfold db migrations create create_users
interfold db migrations list --site <site-id>

list returns successful cloud migration receipts without reading local migration files. apply compares the ordered local migration prefix with provider history before applying pending files.

When an API operation fails, the CLI reads the REST error envelope and carries documented recovery metadata from error.details into its structured command error. It keeps REST transport details separate from its own JSON stderr output.

Apply migrations

interfold db migrations apply --site <site-id> --confirm

Always run list immediately before apply. An interrupted request can be recovered by listing again; do not guess whether the provider committed a migration.

Delete permanently

Deletion is a two-step operation:

interfold db delete --site <site-id>
interfold db delete --site <site-id> --confirm DELETE-XXXXXXXX

The first command creates a short-lived challenge and changes nothing. Export important data before confirming deletion.

See Databases for direct-query behavior, runtime queries, and migration-file rules.

On this page