1

I am trying to alter the sequence using liquibase from databases "Oracle" and "Postgres"

get the sequence current_value and incrementBy and set to the minvalue = current_value + incrementBy and start = current_value + incrementBy. below is the changeset sample.

<changeSet  author="liquibase-docs"  id="dropSequence-exampl3e">  
    <alterSequence  incrementBy="80" startValue="(select last_value from frm_main.R_CBA_CHGBK_DTL_IDS)+(example_id_seq.incrementBy)" 
            minValue="(select last_value from frm_main.R_CBA_CHGBK_DTL_IDS)+(example_id_seq.incrementBy)"
            ordered="false" sequenceName="example_id_seq" />
</changeSet>

how to get the sequence current_value and incrementBy values from database?
is that possible to above or is there any other way to do using the liquibase?
we need to solve the above using liquibase only.
do we have any possibility to achieve the above using liquibase and hibernate?

thanks in advance.

Gaali Prabhakar
  • 583
  • 6
  • 23

1 Answers1

0

Probably not the most optimal solution, however, you can run db specific queries in sql blocks to achieve your goal:

<changeSet author="foo" id="1" dbms="postgresql">
    <comment>Alter table</comment>
    <sql>
        ALTER SEQUENCE ...
    </sql>
</changeSet>

and then similar for oracle.

kofemann
  • 4,217
  • 1
  • 34
  • 39