Postgres SERIAL and BIGSERIAL are created as INT / BIGINT without auto increment
See original GitHub issueThe 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:
- Created 4 years ago
- Reactions:7
- Comments:12 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is there any news on this?
I solved this problem for myself simply by explicitly adding
autoIncrement