question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

It is generating empty alterSequence when using with PostgreSQL

See original GitHub issue

Environment

Spring Boot, Hibernate 5, Gradle

Liquibase Version: 4.6.1

Liquibase Integration & Version: <Pick one: CLI, maven, gradle, spring boot, servlet, etc.> gradle - 4.6.1 spring boots

Liquibase Extension(s) & Version:

Database Vendor & Version: PostgresSQL

Operating System Type & Version:

  • macOS

Description

It generates changelog corretly, but it adds empty alterSequence at the end

    <changeSet author="jenik (generated)" id="1637177424360-1">
        <alterSequence sequenceName="hibernate_sequence"/>
    </changeSet>
    <changeSet author="jenik (generated)" id="1637177424360-2">
        <alterSequence sequenceName="revision_sequence_generator"/>
    </changeSet>

It seems like there is the bug in JIRA since 2016: https://liquibase.jira.com/browse/CORE-2495

Additional Context

I am considering writing script removing the alterSequences manually. 😄

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
JanCizmarcommented, Jan 26, 2022

Right, I am using single sequence for most entities. So I excluded just that one.

@MappedSuperclass
@Audited
abstract class StandardAuditModel : AuditModel() {
  @Id
  @SequenceGenerator(
    name = "sequenceGenerator",
    sequenceName = "hibernate_sequence",
    initialValue = 1000000000,
    allocationSize = 100
  )
  @GeneratedValue(
    strategy = GenerationType.SEQUENCE,
    generator = "sequenceGenerator"
  )
  val id: Long = 0
...
1reaction
oguzhancevikcommented, Jan 26, 2022

Hi, is that bug fixed? Some people encounter the same problem, but I guess liquibase has not fixed that bug.

Environment

  • macOS Big Sur (M1)
  • Java 17
  • Spring Boot - 2.6.2
  • Liquibase - 4.5.0
  • liquibase hibernate5 - 4.1.1 (using liquibase-maven plugin)

changelog.yaml

databaseChangeLog:
- changeSet:
    id: 1643182253801-1
    author: oguzhan.cevik (generated)
    changes:
    - alterSequence:
        sequenceName: order_product_seq
- changeSet:
    id: 1643182253801-3
    author: oguzhan.cevik (generated)
    changes:
    - alterSequence:
        sequenceName: orders_seq

error message

Error setting up or running Liquibase:
liquibase.exception.MigrationFailedException: Migration failed for change set liquibase/diff/change-log-2022-01-26-07-30-oguzhan.cevik.yaml::1643182253801-1::oguzhan.cevik (generated):
     Reason: liquibase.exception.DatabaseException: ERROR: syntax error at end of input
  Position: 33 [Failed SQL: (0) ALTER SEQUENCE order_product_seq]

related link https://stackoverflow.com/q/60299107/7927573

Read more comments on GitHub >

github_iconTop Results From Across the Web

Liquibase generating empty ALTER SEQUENCE changes
My database is PostgreSQL 12. What am I missing? Is there a way to prevent liquibase from creating these changes?
Read more >
Documentation: 15: ALTER SEQUENCE - PostgreSQL
ALTER SEQUENCE changes the parameters of an existing sequence generator. Any parameters not specifically set in the ALTER SEQUENCE command retain their prior ......
Read more >
Why does Postgres generate an already used PK value?
PostgreSQL will not try to insert duplicate values on its own, it is you (your application, ORM included) who does. It can be...
Read more >
How to Duplicate a Table in PostgreSQL - PopSQL
Sometimes it's useful to duplicate a table: create table dupe_users as (select * from users);
Read more >
ALTER SEQUENCE - Oracle Help Center
Use the ALTER SEQUENCE statement to change the increment, minimum and maximum values, ... Use this clause to generate unique sequence numbers across...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found