Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update type of a column in liquibase

I want to update the type of a column named "password". At the moment it has type NVARCHAR(40) and I want it to be of type NVARCHAR(64). This is what I did:

<changeSet id="1 - change password length" author="chris311">
    <update tableName="tablename">
        <column name="password" type="NVARCHAR(64)"/>
    </update>
</changeSet>

What else is there to do? Because this obviously does not change anything in the DB.

like image 691
Chris311 Avatar asked Sep 12 '13 13:09

Chris311


People also ask

How do I update columns in Liquibase?

Step 1: Add the update Change Type to your changeset with the needed attributes as it is shown in the examples. Step 2: Deploy your changeset by running the update command. Now, you should see an updated table. Note: You can use the update Change Type in combination with loadData and loadUpdateData Change Types.

What is change type in Liquibase?

Liquibase Concepts Simply put – a changelog contains an ordered list of changesets, and a changeset contains a change. You and your team can specify database changes in one of four different changelog formats: SQL, XML, JSON, or YAML. And, you can even mix and match different types of changelogs, if desired.


2 Answers

You're using the wrong refactoring operation. Try modifyDataType

like image 60
Mark O'Connor Avatar answered Sep 20 '22 01:09

Mark O'Connor


<changeSet id="increase-password-length" author="martin">
  <modifyDataType tableName="tablename" columnName="password" newDataType="NVARCHAR(64)"/>
</changeSet>

You can check out http://www.liquibase.org/documentation/changes/modify_data_type.html for more documentation

like image 29
Martin Rugadya Avatar answered Sep 21 '22 01:09

Martin Rugadya