Liquibase to add index for foreign key for postgres


I’d like to have liquibase to automatically add indexes for all foreign keys created via statements.

We use MySQL and PostgreSQL, and for MySQL this is done by MySQL, but it is not done for PostgreSQL.

Is there a setting or a configuration so regardless whether MySQL or PostreSQL is used, we end up having indexes on all foreign keys?

My best solution I’ve come up so far would be to do this via the following CusomChange:

public class AddForeignKeyConstraintWithIndex extends liquibase.change.core.AddForeignKeyConstraintChange implements liquibase.change.custom.CustomSqlChange {


However I doubt that is the best way to ensure indices are also created for postgres.

I’m happy for all suggestions,

best regards Sebastian