Create Column
Add new columns to existing tables with full control over data types, constraints, and properties.
create()
Create a single column in an existing table.
client.columns.create(tableName: string, column: FieldDefinition): Promise<BolticSuccessResponse<ColumnRecord> | BolticErrorResponse>
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
tableName | string | ✅ | Name of the target table |
column | FieldDefinition | ✅ | Column definition object |
FieldDefinition Properties
| Property | Type | Required | Description |
|---|---|---|---|
name | string | ✅ | Column name (alphanumeric + underscore) |
type | FieldType | ✅ | Column data type |
description | string | ❌ | Human-readable description |
is_nullable | boolean | ❌ | Allow null values (default: true) |
is_unique | boolean | ❌ | Enforce unique values (default: false) |
is_indexed | boolean | ❌ | Create database index (default: false) |
default_value | any | ❌ | Default value for new records |
Examples
Basic Text Column
const { data, error } = await client.columns.create("products", {
name: "title",
type: "text",
is_nullable: false,
is_indexed: true,
description: "Product title",
});
if (!error) {
console.log("Column created:", data.name);
}
Currency Column
const { data, error } = await client.columns.create("products", {
name: "price",
type: "currency",
currency_format: "USD",
decimals: "0.00",
is_nullable: false,
default_value: 0.0,
description: "Product price in USD",
});