@@ -0,0 +1,3542 @@
+package liquibase.diff.output.changelog.core;%0A%0Aimport liquibase.change.Change;%0Aimport liquibase.change.ColumnConfig;%0Aimport liquibase.change.core.CreateIndexChange;%0Aimport liquibase.change.core.DropIndexChange;%0Aimport liquibase.database.Database;%0Aimport liquibase.diff.ObjectDifferences;%0Aimport liquibase.diff.output.DiffOutputControl;%0Aimport liquibase.diff.output.changelog.ChangeGeneratorChain;%0Aimport liquibase.diff.output.changelog.ChangedObjectChangeGenerator;%0Aimport liquibase.structure.DatabaseObject;%0Aimport liquibase.structure.core.Index;%0Aimport liquibase.structure.core.UniqueConstraint;%0Aimport liquibase.util.StringUtils;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Collection;%0Aimport java.util.List;%0A%0Apublic class ChangedIndexChangeGenerator implements ChangedObjectChangeGenerator %7B%0A    @Override%0A    public int getPriority(Class%3C? extends DatabaseObject%3E objectType, Database database) %7B%0A        if (Index.class.isAssignableFrom(objectType)) %7B%0A            return PRIORITY_DEFAULT;%0A        %7D%0A        return PRIORITY_NONE;%0A    %7D%0A%0A    @Override%0A    public Class%3C? extends DatabaseObject%3E%5B%5D runBeforeTypes() %7B%0A        return null;%0A    %7D%0A%0A    @Override%0A    public Class%3C? extends DatabaseObject%3E%5B%5D runAfterTypes() %7B%0A        return null;%0A    %7D%0A%0A    @Override%0A    public Change%5B%5D fixChanged(DatabaseObject changedObject, ObjectDifferences differences, DiffOutputControl control, Database referenceDatabase, Database comparisonDatabase, ChangeGeneratorChain chain) %7B%0A        Index index = (Index) changedObject;%0A%0A        DropIndexChange dropIndexChange = new DropIndexChange();%0A        dropIndexChange.setTableName(index.getTable().getName());%0A%0A        CreateIndexChange addIndexChange = new CreateIndexChange();%0A        addIndexChange.setTableName(index.getTable().getName());%0A        List%3CColumnConfig%3E columns = new ArrayList%3CColumnConfig%3E();%0A        for (String col : index.getColumns()) %7B%0A            columns.add(new ColumnConfig().setName(col));%0A        %7D%0A        addIndexChange.setColumns(columns);%0A        addIndexChange.setIndexName(index.getName());%0A%0A%0A        if (control.isIncludeCatalog()) %7B%0A            dropIndexChange.setCatalogName(index.getSchema().getCatalogName());%0A            addIndexChange.setCatalogName(index.getSchema().getCatalogName());%0A        %7D%0A        if (control.isIncludeSchema()) %7B%0A            dropIndexChange.setSchemaName(index.getSchema().getName());%0A            addIndexChange.setSchemaName(index.getSchema().getName());%0A        %7D%0A%0A        String referenceColumns = StringUtils.join((Collection%3CString%3E) differences.getDifference(%22columnNames%22).getReferenceValue(), %22,%22);%0A        String comparedColumns = StringUtils.join((Collection%3CString%3E) differences.getDifference(%22columnNames%22).getComparedValue(), %22,%22);%0A%0A        control.setAlreadyHandledChanged(new Index().setTable(index.getTable()).setColumns(referenceColumns));%0A        if (!referenceColumns.equalsIgnoreCase(comparedColumns)) %7B%0A            control.setAlreadyHandledChanged(new Index().setTable(index.getTable()).setColumns(comparedColumns));%0A        %7D%0A%0A        if (index.isUnique() != null && index.isUnique()) %7B%0A            control.setAlreadyHandledChanged(new UniqueConstraint().setTable(index.getTable()).setColumns(referenceColumns));%0A            if (!referenceColumns.equalsIgnoreCase(comparedColumns)) %7B%0A                control.setAlreadyHandledChanged(new UniqueConstraint().setTable(index.getTable()).setColumns(comparedColumns));%0A            %7D%0A        %7D%0A%0A        return new Change%5B%5D %7B dropIndexChange, addIndexChange %7D;%0A    %7D%0A%7D%0A

Handle changed indexes