MergeColumns MySql

Hello. I am using MySql database. I wanted to merge 2 columns in a table. (Wanted to test this change type).
I used the following changeset for this:
<mergeColumns tableName = "test" column1Name = "t1" column2Name = "t2" finalColumnName = "t12" finalColumnType = "varchar (100)" joinString = "---" />

Everything goes through successfully, but the result is wrong. The JoinString was incorrectly added at the beginning. Does anyone know why it happens? Thanks in advance!

Example:
t1 = m
t2 = k
Result: t12= ā€”mk

Hi @Lina1,
we are investigating the issue, meanwhile, you can do it with sql like this:

<changeSet author="bob" id="3">
<addColumn tableName="test" >
    <column name="t12" 
        type="varchar(255)"/>   
</addColumn>  
<sql endDelimiter="\nGO"  
     splitStatements="true"  
     stripComments="true">
     UPDATE  liquibase_test.test  SET  t12  =  CONCAT_WS('---', t1, t2);
</sql>  
<dropColumn tableName="test">  
    <column  name="t1"/>
    <column  name="t2"/>
</dropColumn>  

mysql_result

2 Likes

Hi @Lina1,

Did @costinmoraru suggestion resolve your issue?
I have also made a request to update the following docs (thanks for the suggestions @costinmoraru) https://docs.liquibase.com/change-types/community/merge-columns.html

-Ronak

1 Like

Hello,
Yes, the suggestion worked. I came to the solution beforehand, but as part of my bachelor thesis, I am testing how far change types support database refactoring. The use of ā€œmergeColumnsā€ was interesting for me. And I didnā€™t know if it was a bug. If so, when will it be fixed?

Hi @Lina1,

It does look like a bug, and user @costinmoraru already put in a pull request. Please feel free to comment and let the team know it is important:

You should be able to get updates on when it will make it into the product.

-Ronak

2 Likes