---
url: /process-functions/table-fieldadd.md
description: Adds a field to a table in the model.
---

# table.fieldAdd

Adds a field to one of the model's [tables](/technical/tables).

::: tip
For more control, such as other column types, indexes or keys, manage tables with SQL instead. Run `CREATE`, `ALTER` and `DROP TABLE` statements with [DatasourceClient](/process-functions/datasourceclient)'s `execute`.
:::

```js
table.fieldAdd(tableName, fieldName, fieldType)
```

## Parameters

| Parameter | Type | Description |
|---|---|---|
| `tableName` | `string` | The table's name or id. |
| `fieldName` | `string` | The new field's name. |
| `fieldType` | `string` | The field's type, from [Field types](#field-types). |

## Returns

`true` if the field was added, otherwise `false`. The reason is written to the process log.

## Field types

The type names aren't case-sensitive, but must otherwise match exactly.

| Type | MySQL type |
|---|---|
| `CALCULATED NUMERIC` | `DECIMAL(15,5)` |
| `CALCULATED TEXT` | `VARCHAR(512)` |
| `DATE` | `DATE` |
| `DATE TIME` | `TIMESTAMP` |
| `DATE TIME CREATED` | `TIMESTAMP`, defaulting to the current time |
| `DATE TIME LAST UPDATED` | `TIMESTAMP` |
| `FILE ATTACHMENT` | `MEDIUMTEXT` |
| `NUMERIC` | `DECIMAL(15,5)` |
| `REMOTE IDENTIFIER` | `INT(11)` |
| `TEXT [25,000]` | `TEXT(25000)` |
| `TEXT FORMATTED [25,000]` | `TEXT(25000)` |
| `TEXT [512]` | `VARCHAR(512)` |
| `TEXT [55]` | `VARCHAR(55)` |
| `TEXT [LIST]` | `VARCHAR(512)` |
| `TIME` | `TIME` |
| `UNIQUE IDENTIFIER` | `INT`, auto-incrementing |
| `USER ID CREATOR` | `INT(11)` |
| `USER ID LAST MODIFIED` | `INT(11)` |
| `USER ID` | `INT(11)` |
| `YES OR NO` | `TINYINT(1)` |

## Examples

```js
const created = table.fieldAdd("users", "password", "Text [512]");
```

## Related

* [table.fieldRemove](/process-functions/table-fieldremove)
* [table.fieldExists](/process-functions/table-fieldexists)
* [table.fields](/process-functions/table-fields)
