I have a table temp in SQL server created using liquibase
The liquibase changelog of a table temp is
databaseChangeLog:
- changeSet:
author: Author_name
id: create_temp_table
createTable:
tableName: temp
columns:
- column:
name: id
type: BIGINT
constraints:
primaryKey: 'true'
- column:
name: type
type: VARCHAR(255)
- column:
name: reference
type: VARCHAR(255)
- column:
name: rate
type: VARCHAR(255)
I want to modify the rate column from string to decimal. So I create a new changelog file below
databaseChangeLog:
- changeSet:
id: modify_column_temp_table
author: Author_name
changes:
- modifyDataType:
columnName: rate
newDataType: DECIMAL(18,4)
tableName: temp
Now, there is already some exising data in the temp table with rate column as string. When the modify_column_temp_table changelog runs, I understand that SQl Server will throw a cast error saying string can't be cat to decimal.
How can I execute a script or command in the same changelog which actually modifies the data of the column along with the data type so that the existing data in the rate is modified to the new data type?