'How to create Liquibase changeset for below Postgres index creation statement - concat 2 columns in index

create index if not exists employee_index 
   on employee(emp_id, (emp_first_name|| ' ' ||emp_last_name));

I'm able to use the above statement in Postgres, I want to have it in my Liquibase changeset. I need to combine the first and last names as above in the index since it gives better performance. I was told that I can't deviate from it.



Solution 1:[1]

You can create an expression based index by enclosing the expression in parentheses:

<createIndex tableName="employee" indexName="employee_index">
  <column name="emp_id"/>
  <column name="(emp_first_name||' '||emp_last_name)"/>
</createIndex>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 a_horse_with_no_name