> For the complete documentation index, see [llms.txt](https://learn.capstorm.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learn.capstorm.com/frequently-asked-questions/problems-solutions/how-to-fix-cannot-alter-column-used-by-a-view-errors.md).

# How to Fix Cannot Alter Column Used by A View Errors

## How to Fix “*Cannot Alter Column Used by a View*” Errors

There are a handful of tables where CopyStorm uses database views rather than tables. A good example is *ActivityHistory* (a view combining the Task and Event tables). If Salesforce makes a change which alters the type of length of a column in a table and the column is used in an existing view, PostgreSQL will throw an error like the following when CopyStorm tries to make the change in the database.

* org.postgresql.util.PSQLException: ERROR: cannot alter type of a column used by a view or rule Detail: rule \_RETURN on view openactivity depends on column “status”

The process to fix the issue is to:

* Drop the views that depend on the table that needs modification
* Run CopyStorm — it will make the table modification and automatically recreate the views.

## Example From Summer’20

In Summer’20 Salesforce increased then length of the column *Task.Status*. Since the *Task.Status* column is used in CopyStorm views the update to *Task.Status* failed with:

* org.postgresql.util.PSQLException: ERROR: cannot alter type of a column used by a view or rule Detail: rule \_RETURN on view openactivity depends on column “status”

Here are the steps to fix this problem.

### Step 1: Drop the Views Which Depend on Task.Status

![](https://4057376488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsbSqfKw3vSfr8qwXao4j%2Fuploads%2Fgit-blob-04b5540ddc44b3c69d81a8a40d20dc2c3769698f%2F8e6b0500-Open-SQL-Tool.png?alt=media)

![](https://4057376488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsbSqfKw3vSfr8qwXao4j%2Fuploads%2Fgit-blob-2aad21b942eb42f69b0b74ecb5303cf85031c280%2Feb620af9-Drop-Views.png?alt=media)

### Step 2: Run CopyStorm

The next time CopyStorm runs it will:

* Successfully ALTER the Task.Status column because the dependent views no longer exist.
* Recreate the views after detecting they have been deleted.
