addAutoIncrement generated wrong sql
See original GitHub issueEnvironment
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:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top 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 >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
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.
@nvoxland moving this to code review since that is where the PR is living now. Thanks!