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.

Postgres SERIAL and BIGSERIAL are created as INT / BIGINT without auto increment

See original GitHub issue

The following liquibase changeset does not work as expected

        <createTable tableName="test">
            <column name="id" type="SERIAL">
                <constraints nullable="false" primaryKey="true"/>
            </column>
        </createTable>

This changeset results in sql

CREATE TABLE test (id INTEGER NOT NULL, CONSTRAINT TEST_PKEY PRIMARY KEY (id));

In liquibase 3.6.3 and earlier the type SERIAL was used for the column which means that a sequence is automatically included.

This issue seems to be caused by #874 It appears that SERIAL columns are replaced by INT, however liquibase does reconize that this column type is an auto increment column.

It would be acceptible if the generated sql would be

CREATE TABLE test (id INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL, CONSTRAINT TEST_PKEY PRIMARY KEY (id));

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
Trigvecommented, Mar 1, 2021

Is there any news on this?

2reactions
BorzdeGcommented, Mar 9, 2020

I solved this problem for myself simply by explicitly adding autoIncrement

<column name="id" type="SERIAL" autoIncrement="true"/>
Read more comments on GitHub >

github_iconTop Results From Across the Web

H2 equivalent of Postgres `SERIAL` or `BIGSERIAL` column?
If you create a column as auto_increment (or identity ) H2 creates a sequence in the background. The name of that sequence can...
Read more >
Documentation: 9.1: Numeric Types - PostgreSQL
The types smallint, integer, and bigint store whole numbers, that is, numbers without fractional components, of various ranges. Attempts to store values ...
Read more >
PostgreSQL SERIAL or IDENTITY column and Hibernate ...
SERIAL is an auto-incremented integer column that takes 4 bytes while BIGSERIAL is an auto-incremented bigint column taking 8 bytes.
Read more >
Defining an Auto Increment Primary Key in PostgreSQL - Chartio
By far the simplest and most common technique for adding a primary key in Postgres is by using the SERIAL or BIGSERIAL data...
Read more >
Using PostgreSQL SERIAL To Create The Auto-increment ...
First, create a sequence object and set the next value generated by the sequence as the default value for the column. · Second,...
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