# Check for and resolve schema changes

{% hint style="info" %}
Included in the Basic API.
{% endhint %}

Before you start a data generation job, we recommend that you check for and resolve any schema changes on the source database.

In the Tonic Structural application, you can use the [Schema Changes view](/app/generation/schema-changes.md) to review and resolve any changes.

From the API, you can:

* Retrieve a list of schema changes
* Resolve schema changes

## Retrieve the list of schema changes <a href="#tonic-api-schema-changes-retrieve" id="tonic-api-schema-changes-retrieve"></a>

To view the list of schema changes, use [<mark style="background-color:blue;">**GET**</mark>**&#x20;/api/SchemaDiff**](https://app.tonic.ai/apidocs/index.html#/SchemaDiff/GetSchemaDiffs).

In the results, each schema change uses the following format:

```json
{
    "schemaName": "string",
    "tableName": "string",
    "issueCode": "string",
    "columnName": "string",
    "pathName": "string",
    "oldDataType": "string",
    "newDataType": "string"
}
```

Where:

<table data-header-hidden><thead><tr><th width="253" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top"><code>schemaName</code></td><td valign="top">The name of the affected schema. </td></tr><tr><td valign="top"><code>tableName</code></td><td valign="top"><p>The name of the affected table.</p><p></p><p>For MongoDB, this is the name of the affected collection.</p></td></tr><tr><td valign="top"><code>issueCode</code></td><td valign="top"><p>The type of schema change. Possible values are:</p><ul><li><code>new_column</code> - The column was added to the table.</li><li><code>changed_column_type</code> - The column data type changed. Data type changes are only listed if the change introduces a conflict in the workspace configuration.</li><li><code>new_table</code> - The table was added to the schema.</li><li><code>missing_column</code> - The column was removed from the table. Removed columns are only listed if the removal introduces a conflict in the workspace configuration.</li><li><code>missing_table</code> - The table was removed from the schema. Removed tables are only listed if the removal introduces a conflict in the workspace configuration.</li><li><code>changed_nullability</code> - The column changed whether it can be NULL. Nullability changes are only listed if the change introduces a conflict in the workspace configuration.</li><li><code>new_foreign_key</code> - The column had an assigned generator, but is now a foreign key. Foreign keys must inherit the generator from the primary key.</li><li><code>new_collection</code> - For MongoDB and Amazon DynamoDB only. The collection was added to the source database.</li><li><code>missing_collection</code> - For MongoDB and Amazon DynamoDB only. The collection was removed from the source database. Removed collections are only listed if the change introduces a conflict in the workspace configuration.</li><li><code>new_path_type</code> - For MongoDB, Amazon DynamoDB, and JSON fields only. The column has a new path type.</li><li><code>missing_path_type</code> - For MongoDB, Amazon DynamoDB, and JSON fields only. The column path type was removed.</li></ul></td></tr><tr><td valign="top"><code>columnName</code></td><td valign="top">The name of the affected column. For new or removed tables or collections, there is no column name.</td></tr><tr><td valign="top"><code>pathName</code></td><td valign="top">The affected path. For JSON fields only, for <code>new_path_type</code> and <code>missing_path_type</code> issues.</td></tr><tr><td valign="top"><code>oldDataType</code></td><td valign="top">For columns that change type, the previous data type.  </td></tr><tr><td valign="top"><code>newDataType</code></td><td valign="top">For a new column, the data type of the column.<br><br>For columns that change type, the new data type.</td></tr></tbody></table>

## Resolve selected schema changes <a href="#tonic-api-schema-schanges-resolve" id="tonic-api-schema-schanges-resolve"></a>

You can use the API to resolve specified schema changes.

When you use the API to resolve schema changes:

* For information on how Structural resolves sensitive schema changes (new tables and columns), go to [Viewing and resolving schema changes](/app/generation/schema-changes.md#schema-changes-resolve-conflicting).
* For information on how Structural resolves notifications (removed tables and columns), go to [Viewing and resolving schema changes](/app/generation/schema-changes.md#schema-changes-dismiss-non-conflicting).

To resolve a single schema change, use [<mark style="background-color:green;">**POST**</mark>**&#x20;/api/SchemaDiff/resolve**](https://app.tonic.ai/apidocs/index.html#/SchemaDiff/Resolve). The request body provides the details for a single schema change.

To resolve multiple changes, use [<mark style="background-color:green;">**POST**</mark>**&#x20;/api/SchemaDiff/resolve\_multiple**](https://app.tonic.ai/apidocs/index.html#/SchemaDiff/ResolveMultiple). The request body provides the details for each schema change.

In the request body, each schema change has the following format:

```json
{
  "workspaceId": "string",
  "issueCode": "new_column",
  "schemaName": "string",
  "tableName": "string",
  "columnName": "string",
  "pathName": "string",
  "dataType": "string"
}
```

Where:

<table data-header-hidden><thead><tr><th width="268" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top"><code>workspaceId</code></td><td valign="top">The identifier of the workspace.</td></tr><tr><td valign="top"><code>issueCode</code></td><td valign="top">The type of issue.</td></tr><tr><td valign="top"><code>schemaName</code></td><td valign="top">The name of the affected schema.</td></tr><tr><td valign="top"><code>tableName</code></td><td valign="top">The name of the affected table.</td></tr><tr><td valign="top"><code>columnName</code></td><td valign="top">The name of the affected column. Only provided for column-specific issues.</td></tr><tr><td valign="top"><code>pathName</code></td><td valign="top">For JSON fields only. The affected path. Provided for path-specific issues.</td></tr><tr><td valign="top"><code>dataType</code></td><td valign="top">For MongoDB, Amazon DynamoDB, and JSON fields only. The data type for the affected column.</td></tr></tbody></table>

## Resolving all schema changes for a workspace <a href="#api-schema-changes-resolve-all" id="api-schema-changes-resolve-all"></a>

To resolve all schema changes for a workspace, use:

[<mark style="background-color:green;">**POST**</mark>**&#x20;/api/SchemaDiff/{workspaceId}/resolve\_all**](https://app.tonic.ai/apidocs/index.html#/SchemaDiff/ResolveAll)

The `resolutionOption` parameter identifies the types of schema changes to resolve. The options are:

* `All` - Indicates to resolve all of the schema changes.
* `Actions` - Indicates to only resolve sensitive schema changes.
* `Notifications` - Indicates to only resolve notifications.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tonic.ai/app/api/quick-start-guide/tonic-api-schema-changes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
