Alter column length with liquibase

liquibase

I am having problems changing a column length in my postgres db with liquibase.

I have a table account with a field description varchar(300). I want to change it to varchar(2000).

I have dropped and recreated the primary key in the same file so I don't have permissions issues or schema / db names or anything like this. For the sake of testing I have cleared the table of data.

I am running

<changeSet author="liquibase" id="sample">
    <modifyDataType
        columnName="description"
        newDataType="varchar(2000)"
        schemaName="accountschema"
        tableName="account"/>
</changeSet>

I'm getting this error text but I can't understand the issue. The only constraint the column had was a not null constraint and I successfully added a separate changelog to remove this constraint (ignoring the fact I don't see why this would affect extending the length of the field).

Can anyone point to what I am doing wrong?

Best Answer

You can increase the size of your column like this:

<changeSet author="liquibase" id="sample">
    <modifyDataType
        columnName="description"
        newDataType="varchar(2000)"
        tableName="account"/>
</changeSet>
Related Topic