---
title: "Update Table Schema"
method: PATCH
path: "/api/database/tables/{tableName}/schema"
tags: ["Admin"]
---

# Update Table Schema

`PATCH /api/database/tables/{tableName}/schema`

## Path parameters

- `tableName` string, required

## Request body

- object
  - `addColumns` object[] — Add new columns to the table
    - `columnName` string, required — Name of the new column
    - `type` 'string' | 'integer' | 'float' | 'boolean' | 'datetime' | 'uuid' | 'json' | 'file', required — Data type of the column
    - `isNullable` boolean — Whether the column allows NULL values
    - `isUnique` boolean — Whether the column values must be unique
    - `defaultValue` string — Default value for the column
  - `dropColumns` string[] — Remove columns from the table
  - `updateColumns` object[] — Modify existing columns (rename or change default)
    - `columnName` string, required — Current name of the column
    - `newColumnName` string — New name for the column (optional)
    - `defaultValue` string — New default value for the column (optional)
  - `addForeignKeys` ForeignKeyConstraint[] — Add foreign key constraints (one entry per constraint; composite keys list multiple column mappings)
    - `constraintName` string — Constraint name. Returned when reading the schema; derived by the backend on create.
    - `referenceTable` string, required — Table being referenced
    - `referenceColumns` object[], required — Ordered (source → reference) column pairs
      - `sourceColumn` string, required — Column in the current table
      - `referenceColumn` string, required — Column in the referenced table
    - `onDelete` 'CASCADE' | 'SET NULL' | 'SET DEFAULT' | 'NO ACTION' | 'RESTRICT', required
    - `onUpdate` 'CASCADE' | 'SET NULL' | 'SET DEFAULT' | 'NO ACTION' | 'RESTRICT', required
  - `dropForeignKeys` string[] — Constraint names of foreign keys to drop
  - `renameTable` object — Rename the table
    - `newTableName` string, required — New name for the table

## Response `200`

Table schema updated successfully

- object
  - `message` string — Success message
  - `tableName` string — Name of the updated table
  - `operations` string[] — List of operations performed

## Other responses

- `400` — Bad request
- `404` — Table not found

---

[API](https://skmtc.net/insforge/apis/insforge-authentication-api.md) · [All operations](https://skmtc.net/insforge/apis/insforge-authentication-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/insforge/insforge-authentication-api/versions/a935bb49f932/schema)
