Alter sequence in H2
<p>I'm using Postgres database in production and H2 for tests.
I want to create a new sequence for an existing table - so in Liquibase I wrote this:</p>

<pre><code>&lt;changeSet id="Add sequence for BOOKS" author="library"&gt;
    &lt;createSequence sequenceName="BOOKS_SEQ" incrementBy="500" startValue="1"/&gt;
&lt;/changeSet&gt;
</code></pre>

<p>My Entity looks like this:</p>

<pre><code>@Entity
@Table(name = "BOOKS")
@SequenceGenerator(name = "BOOKS_SEQ", allocationSize = 500)
public class Book {

    @Id
    @GeneratedValue(generator = "BOOKS_SEQ", strategy = GenerationType.TABLE)
    private Long id;

    @ManyToOne
    @JoinColumn(name = "AUTHOR_ID")
        private Author author;
...

}
</code></pre>

<p>Now, since I already have entities in this table (with Ids from the last sequence I used), I need to set the current value of this sequence accordingly.
For that matter I wrote:</p>

<pre><code>&lt;changeSet id="Alter sequence for BOOKS" author="library"&gt;
    &lt;sql dbms="postgresql"&gt;select setval('BOOKS_SEQ', (select nextval('OLD_SEQUENCE_UID')))&lt;/sql&gt;
&lt;/changeSet&gt;

&lt;changeSet id="Add default value to BOOKS.ID" author="library"&gt;
    &lt;addDefaultValue tableName="BOOKS" columnName="ID" defaultValueSequenceNext="BOOKS_SEQ"/&gt;
&lt;/changeSet&gt;
</code></pre>

<p>In Postgres (production), it seems to work just fine - but in H2 I get an error message "The sequence named [BOOKS_SEQ] is setup incorrectly.  Its increment does not match its pre-allocation size".</p>

<p>According to <a href="https://stackoverflow.com/questions/18474046/eclipselink-and-sequence-generator-preallocation">this</a> - I need to set the start_value (or current value) to something greater than 500 - but I can't figure out how this can be <a href="http://www.h2database.com/html/grammar.html#alter_sequence" rel="noreferrer">done in H2</a>.</p>

<p>So my question is: How can I set the current value of a sequence in H2?</p>