Managed databases
SDK reference for managed databases — Inspect managed databases, work with rows, and manage connections and migrations.
Inspect managed databases, work with rows, and manage connections and migrations.
list
List managed databases for the active deployment, with their tables and migration status
GET
Usage:
const result = await swirls.client.managedDatabases.list({
projectId: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
projectId | string | Yes |
schema
Full table + column schema of one managed database, for SQL editor autocomplete
GET
Usage:
const result = await swirls.client.managedDatabases.schema({
projectId: '...',
database: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
projectId | string | Yes | |
appName | string | No | |
database | string | Yes |
Output:
| Field | Type | Description |
|---|---|---|
tables | object[] |
listRows
Read a page of rows from one table of a managed database (read-only), with optional server-side sort, filter, and search
GET
Usage:
const result = await swirls.client.managedDatabases.listRows({
projectId: '...',
database: '...',
table: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
projectId | string | Yes | |
appName | string | No | |
database | string | Yes | |
table | string | Yes | |
limit | number | No | |
offset | number | No | |
orderBy | object | No | |
filters | object[] | No | |
search | string | No | |
ids | string[] | No |
Output:
| Field | Type | Description |
|---|---|---|
columns | object[] | |
rows | object[] | |
totalCount | number |
insertRow
Insert one row into a managed-database table (schema-allowlisted columns)
POST
Usage:
const result = await swirls.client.managedDatabases.insertRow({
projectId: '...',
database: '...',
table: '...',
fields: {},
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
projectId | string | Yes | |
appName | string | No | |
database | string | Yes | |
table | string | Yes | |
fields | object | Yes |
updateRow
Patch one row in a managed-database table. Primary-key mutation is refused.
POST
Usage:
const result = await swirls.client.managedDatabases.updateRow({
projectId: '...',
database: '...',
table: '...',
id: '...',
fields: {},
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
projectId | string | Yes | |
appName | string | No | |
database | string | Yes | |
table | string | Yes | |
id | string | Yes | |
fields | object | Yes |
deleteRow
Delete one row from a managed-database table by primary key
POST
Usage:
const result = await swirls.client.managedDatabases.deleteRow({
projectId: '...',
database: '...',
table: '...',
id: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
projectId | string | Yes | |
appName | string | No | |
database | string | Yes | |
table | string | Yes | |
id | string | Yes |
Output:
| Field | Type | Description |
|---|---|---|
id | string |
runQuery
Run a SQL query against a managed database (SQL console). Read-only owner connection.
POST
Usage:
const result = await swirls.client.managedDatabases.runQuery({
projectId: '...',
database: '...',
sql: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
projectId | string | Yes | |
database | string | Yes | |
sql | string | Yes |
Output:
| Field | Type | Description |
|---|---|---|
columns | object[] | |
rows | object[] | |
rowCount | number | |
truncated | boolean | |
durationMs | number |
listConnections
List named connections provisioned for a managed database block
GET
Usage:
const result = await swirls.client.managedDatabases.listConnections({
projectId: '...',
database: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
projectId | string | Yes | |
appName | string | No | |
database | string | Yes |
revealConnection
Reveal the connection string for a managed database connection (requires deployments:write)
POST
Usage:
const result = await swirls.client.managedDatabases.revealConnection({
projectId: '...',
database: '...',
connection: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
projectId | string | Yes | |
appName | string | No | |
database | string | Yes | |
connection | string | Yes |
Output:
| Field | Type | Description |
|---|---|---|
directUrl | string | |
pooledUrl | string |
rotateConnection
Rotate a managed database connection and return the new connection string
POST
Usage:
const result = await swirls.client.managedDatabases.rotateConnection({
projectId: '...',
database: '...',
connection: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
projectId | string | Yes | |
appName | string | No | |
database | string | Yes | |
connection | string | Yes |
Output:
| Field | Type | Description |
|---|---|---|
directUrl | string | |
pooledUrl | string |
migrationStatus
Per-database migration detail for the active deployment (status, gate reason, applied and pending data migrations)
GET
Usage:
const result = await swirls.client.managedDatabases.migrationStatus({
projectId: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
projectId | string | Yes |
approveMigration
Approve a gated managed-database migration, kicking an approved re-run of the migration workflow
POST
Usage:
const result = await swirls.client.managedDatabases.approveMigration({
projectId: '...',
database: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
projectId | string | Yes | |
database | string | Yes |
Output:
| Field | Type | Description |
|---|---|---|
started | true | |
deploymentId | string |
recycle
Replace a managed database with a new empty instance and remove the old instance. Existing data is not copied. Deploy-time migrations recreate the schema on the next deploy.
POST
Usage:
const result = await swirls.client.managedDatabases.recycle({
projectId: '...',
database: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
projectId | string | Yes | |
database | string | Yes |
Output:
| Field | Type | Description |
|---|---|---|
externalDatabaseId | string | |
previousExternalDatabaseId | string | |
health | object |