LiquiBase adding multiple columns in PostgreSQL

Hello there,

I am yet to use/implement LiquiBase tool for our PostgreSQL databases. One question i have is -

Can LiquiBase be used to add multiple columns part of one changeset all at a time generating a one single “ALTER TABLE” command ?

Meaning - If i wish to add 3 columns to a table, then the following command must be applied as an SQL to the database

ALTER TABLE TEST ADD COLUMN , ADD COLUMN , ADD COLUMN ;

What i understand is that, liquibase generates 3 individual “ALTER TABLE” commands - please correct me if i am wrong. I would like to know if it is possible to do something similar to the above

Thanks in advance !

You are correct - Liquibase will generate individual alter table statements, one for each column added.

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

Thanks Steve !

Recently, one of customers were adding multiple columns to a big table with 15m rows and were looking at speeding up the process. We could not manage to club all the “ALTER TABLE… ADD COLUMN” commands into one single command because they were using Liquibase to track their database changes being applied and was generating individual ALTER TABLE statements for each column.

I believe, it would be good if liquibase generates a single ALTER TABLE statement for all the columns being added and modified.

Any thoughts would be appreciated !

Thanks.

I was going to suggest that you submit a pull request to fix this, but it appears that someone beat you to it! I went and looked at the history for the class that generates the SQL for adding columns, and a pull request was merged 10 days ago that appears to do what you want. This will be in the 3.4.2 release I think. I’m not sure what the plan is for when that will be released.

https://liquibase.jira.com/browse/CORE-1833

https://github.com/liquibase/liquibase/commit/96bf5a5eeaf12b2668a7a2efb1aa3a7d2f29c180

https://github.com/liquibase/liquibase/commit/50552f2bc9d2d1db7b472ce7c85fa9c546080af4

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

https://github.com/liquibase/liquibase/pull/315

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

I have not tested it, but the code appears to be database-platform agnostic and should work on all supported databases.

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

Hi Steve,

I just came to know that, the change is effective in MySQL database only not in PostgreSQL database. I am further working on this.

Thanks,

Venkat

Hi Steve,

Thank you very much for the quick reply. Thats great to know !

I have been through the “github” link, it says the fix has been done for MySQL. I am not sure if it applies for PostgreSQL as well. Can you please help.

Regards,

Venkat

Thank you very much Steve for the reply again.

I will take this up further.

Thanks,

Venkat