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.

addAutoIncrement generated wrong sql

See original GitHub issue

Environment

Liquibase Version:3.8.8

Liquibase Integration & Version: run as jar File

Liquibase Extension(s) & Version: NO

Database Vendor & Version:PostgreSQL 11.1

Operating System Type & Version:Windows10

Description

The following change set produced Exception because the generater sql syntax is invalid. //it s working for db2 but doesn’t work for POSTGRESQL

Steps To Reproduce

<addAutoIncrement  tableName="MYTABEL"	columnName="ID" defaultOnNull="true" generationType="ALWAYS" incrementBy="1" startWith="1"/>

Actual Behavior

CREATE SEQUENCE public.MYTABEL_id_seq AS null NO CACHE NOORDER liquibase.exception.MigrationFailedException: Migration failed for change set path-ignored::db-changelog-tables-1.0.0::Reza: Reason: liquibase.exception.DatabaseException: ERROR: syntax error at or near “null”

Expected/Desired Behavior

ALTER TABLE MYTABEL DROP COLUMN ID; ALTER TABLE MYTABEL ADD COLUMN ID SERIAL PRIMARY KEY; COMMENT ON COLUMN MYTABEL.ID IS ‘The entry ID’;

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nvoxlandcommented, Mar 1, 2022

I think the original issue was resolved by a different fix at some point. There was a problem where we weren’t handling the “sequence data type” setting correctly, and I think that’s where the null came from.

BUT, I’ll keep this open for testing with #2588 because the generationType/defaultOnNull validation error is fixed there, and the example in the REPO steps use incrementBy/startWith on postgresql which were fixed by that PR also.

0reactions
kataggartcommented, May 23, 2022

@nvoxland moving this to code review since that is where the PR is living now. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQL create statement incorrect syntax near auto increment
It is IDENTITY not AUTO_INCREMENT in SQL Server. Try this instead: CREATE TABLE [dbo].[MY_TABLE] ( [ID] INT NOT NULL IDENTITY(1, 1), ...
Read more >
addAutoIncrement isn't working properly for HyperSQL, Mysql ...
Syntax error in SQL statement "ALTER TABLE PUBLIC.autoincrement_test ALTER COLUMN intColumn int GENERATED BY DEFAULT AS IDENTITY ([*]100, 2)"; ...
Read more >
addAutoIncrement | Liquibase Docs
The addAutoIncrement changetype converts an existing column to be an ... generationType, Type of the generation in 'GENERATED %s AS IDENTITY'.
Read more >
Add autoincrement to existing PK - DBA Stack Exchange
First off, in case something goes wrong: BEGIN TRANSACTION;. Now, let's add a temporary work column, id_temp and set that column to the...
Read more >
Bug when set an existing column as auto increment primary key
DBE-8721 `Create New Table` generates SQL that is not accepted by MySQL when {Auto ... primary keys with auto_increment set and does commands...
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