Skip to main content
The tables module manages the schema of your custom tables — creating and dropping tables, and adding and dropping columns. For reading and writing rows, see Tables — Rows. For the feature overview, see Custom Tables.
Table management is service-key only, so it lives in the server-side @sublay/node SDK only — the browser @sublay/js SDK and the React useTable hook are row-only. The same operations are also available in the dashboard data editor.
All names you pass are logical — Sublay applies the custom_ prefix for you.

createTable

Creates a custom table with the given columns and managed-column flags.
string
required
The logical table name (max 56 characters — 63 minus the custom_ prefix). Sublay stores it as custom_<tableName>.
CustomColumnDefinition[]
required
The developer columns to create. Each is { columnName, dataType, nullable, defaultValue? }. dataType is one of text, integer, float, decimal, boolean, date, timestamp, uuid, json. A column may not be named id, createdAt, updatedAt, or deletedAt (reserved managed columns).
boolean
Emit createdAt / updatedAt. Defaults to true.
boolean
Emit deletedAt and enable soft delete. Requires timestamps. Defaults to false.
ReturnsPromise<{ table: string }> — the physical (custom_*) table name.
Errors are returned with a database/* code: database/reserved-column (a column shadows a managed name), database/name-too-long (over 56 chars), database/table-limit-reached (100 tables), database/column-limit-reached (100 columns).

addColumn

Adds a column to an existing custom table.
string
required
The logical table name.
string
required
The new column’s name (may not be a reserved managed name).
CustomColumnType
required
One of text, integer, float, decimal, boolean, date, timestamp, uuid, json.
boolean
required
Whether the column accepts null.
string | null
Optional default literal, validated against dataType.
ReturnsPromise<{ added: string }>

dropColumn

Drops a column from a custom table. Managed columns (id, createdAt, updatedAt, deletedAt) cannot be dropped.
string
required
The logical table name.
string
required
The column to drop.
ReturnsPromise<{ dropped: string }>

dropTable

Drops a custom table and all of its rows. This is irreversible.
string
required
The logical table name.
ReturnsPromise<{ dropped: string }>