Hi ElRubio,
From my tests, even when using the following xml (with only one changeSet) liquibase will do it in two different pt-osc runs:
<changeSet id="1" author="A">
<createIndex tableName="t1" indexName="idx1"
xmlns:liquibasePercona="http://www.liquibase.org/xml/ns/dbchangelog-ext/liquibase-percona"
liquibasePercona:usePercona="true">
<column name="col1"/>
</createIndex>
<createIndex tableName="t1" indexName="idx2"
xmlns:liquibasePercona="http://www.liquibase.org/xml/ns/dbchangelog-ext/liquibase-percona"
liquibasePercona:usePercona="true">
<column name="col2"/>
</createIndex>
</changeSet>
</databaseChangeLog>
I checked in two ways. First, the liquibase update-sql output will show:
-- pt-online-schema-change ... --alter="ADD INDEX idx1 (col1)" --password=*** --execute h=localhost,P=3306,u=root,D=test,t=t1;
-- Instead of the following statements, pt-online-schema-change will be used;
CREATE INDEX idx1 ON test.t1(col1);
-- pt-online-schema-change ... --alter="ADD INDEX idx2 (col2)" --password=*** --execute h=localhost,P=3306,u=root,D=test,t=t1;
-- Instead of the following statements, pt-online-schema-change will be used;
CREATE INDEX idx2 ON test.t1(col2);
And when enabling the MySQL general log and running liquibase update, I saw it indeed used two different ALTER TABLE cycles (one for each pt-osc invocation):
2022-12-29T00:38:07.016117Z 33 Query CREATE TABLE `test`.`_t1_new` (
...
2022-12-29T00:38:07.035309Z 33 Query ALTER TABLE `test`.`_t1_new` ADD INDEX idx1 (col1)
...
2022-12-29T00:38:07.072460Z 33 Query RENAME TABLE `test`.`t1` TO `test`.`_t1_old`, `test`.`_t1_new` TO `test`.`t1`
2022-12-29T00:38:07.086774Z 33 Query DROP TABLE IF EXISTS `test`.`_t1_old`
...
2022-12-29T00:38:07.336200Z 35 Query CREATE TABLE `test`.`_t1_new` (
...
2022-12-29T00:38:07.350686Z 35 Query ALTER TABLE `test`.`_t1_new` ADD INDEX idx2 (col2)
...
2022-12-29T00:38:07.396281Z 35 Query RENAME TABLE `test`.`t1` TO `test`.`_t1_old`, `test`.`_t1_new` TO `test`.`t1`
2022-12-29T00:38:07.413472Z 35 Query DROP TABLE IF EXISTS `test`.`_t1_old`
If it had used pt-osc once, we should have seen:
2022-12-29T00:33:47.715386Z 19 Query ALTER TABLE `test`.`_t1_new` ADD index idx1 (col1), add index idx2 (col2)
I suggest that you do your own tests in this case, because I’m not a liquibase expert at all, and may have missed something. Also, asking this in a liquibase-specific forum may also yield good results.
Let me know if I can help with anything else.
Best,
AgustĂn.