1

We have a Project with activiti and liquibase dependecies. Activiti is automatically configured (exc. 'spring.activiti.async-executor-activate' and 'spring.activiti.database-schema-update' params in application.yml) and liquibase too (exc. 'spring.liquibase.change-log').

Now we need to rebuild indexes on activiti tables (ACT_*) with special liquibase changesets like <sql>alter index ... rebuild tablespace ...</sql>.

There is no problem on existing database, but it crashes on first app start with DB installation because of liquibase is trying to change a nonexistent ACT_* indexes.

How can I start liquibase after activiti DB installation considering Spring Boot autoconfiguration?

antropoff
  • 111
  • 2
  • 3
  • 14

1 Answers1

2

You could control the execution of these changesets by using preconditions. For example:

<changeSet id="1"  author="bob">  
    <preConditions onFail="MARK_RAN">  
        <indexExists>your_act_index</indexExists>  
    </preConditions>  
    <sql>alter index ... rebuild tablespace ...</sql>
</changeSet>  

This way indexes are only rebuilt if they exists, which is not the case on an empty database.

veljkost
  • 1,748
  • 21
  • 25
  • Thanks for reply, but in this way indexes will not be rebuild at all: at first app start preConditions will work, on subsequent launches this script will already be in DATABASECHANGELOG table and thus will not start. Am I wrong? – antropoff Jun 08 '20 at 12:00
  • You are correct, if you say `onFail=MARK_RAN` it will never be run again, but do you realy want to run rebuild of indeces on a fresh new database? If you do, you could maybe say `onFail=CONTINUE`, so it will try to execute it on the next starup. – veljkost Jun 08 '20 at 13:58