> For the complete documentation index, see [llms.txt](https://docs.acpt.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.acpt.io/developers/functions/sync_acpt_table.md).

# sync\_acpt\_table

Synchronise the physical database table with the stored definition

Synchronise the physical database table with the stored definition.

Handles both cases automatically: creates the table from scratch when it does not exist yet, or applies the diff (ALTER / ADD / DROP statements) when it exists but is out of date. Returns `true` immediately when the table is already in sync. This is the preferred function for applying schema changes — use `create_acpt_table()` only when you need to explicitly control the action.

### Usage

```php
// Save the definition first, then sync
save_acpt_table([
    'name'       => 'products',
    'label'      => 'Products',
    'timestamps' => true,
    'columns'    => [
        ['name' => 'title', 'uiType' => 'Text'],
        ['name' => 'price', 'uiType' => 'Currency'],
    ],
]);

sync_acpt_table('products');
```

### Parameters

| Parameter   | Type   | Required | Description               |
| ----------- | ------ | -------- | ------------------------- |
| `tableName` | string | Required | Machine name of the table |

### Return

| Type   | Description                                                                                                         |
| ------ | ------------------------------------------------------------------------------------------------------------------- |
| `bool` | `true` on success or when the table is already in sync, `false` on error or when the table definition was not found |
