Skip to main content

Rename Table

Rename a table while preserving all data, schema, and metadata using the client.tables.rename() method. This operation updates the table name without affecting the table structure or records.

Method Signature

client.tables.rename(oldName: string, newName: string): Promise<ApiResponse<TableRecord>>

Parameters

ParameterTypeRequiredDescription
oldNamestringCurrent table name
newNamestringNew table name

Return Value

Returns the updated TableRecord with the new name:

interface TableRecord {
id: string; // Unique table identifier
name: string; // Table name
account_id: string; // Account identifier
internal_db_name: string; // Database name
db_id?: string; // Database UUID
resource_id?: string; // Resource identifier
description?: string; // Table description
type?: string; // Table type
parent_table_id?: string; // Parent table reference
is_deleted: boolean; // Soft-delete status
is_public: boolean; // Public visibility
created_by: string; // Creator identifier
created_at: string; // Creation timestamp
updated_at: string; // Last update timestamp
updated_by: string; // Last updater identifier
source?: "boltic" | "copilot"; // Creation source
account_status?: "active" | "suspended" | "deleted"; // Account status
}

Example

import { createClient } from "@boltic/sdk";

const client = createClient("your-api-key");

const { data: renamedTable, error } = await client.tables.rename("old_products", "products");

if (error) {
console.error("Failed to rename table:", error.message);
} else {
console.log(`Table renamed successfully:`);
console.log(`- Old name: old_products`);
console.log(`- New name: ${renamedTable.name}`);
console.log(`- Table ID: ${renamedTable.id} (unchanged)`);
}