Skip to content
Advertisement

Create index with multiple columns

How can I create index with multile columns in liquibase yaml.

CREATE UNIQUE INDEX example_index ON table_test(LOWER(id), author, name)

I was trying to do something like that:

-createIndex:
 -indexName: example_index
 -tableName: table_test
 -columns:
  -column:
   name: LOWER(id)
  -column:
   name: author
  -column:
   name: name

But I am getting error column 'name' is required for all columns in an index. I saw similar questions, but answers/examples was written in xml and it was not working for me.

Advertisement

Answer

changeSet:  
  id:  createIndex-example
  author:  liquibase-docs 
  changes: 
  - createIndex: 
     columns:  
     - column:
        name:  zip_code
     - column:
        name:  address 
     indexName:  idx_address 
     tableName:  person 

Above worked for me,

https://docs.liquibase.com/change-types/community/create-index.html

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement