How to insert auto_increment in an already created table in liquibase?
User table already exists.
<createTable tableName="user">
<column name="user" type="varchar(255)">
<constraint nullable="false">
</column>
<column name="user_id" type="varchar(255)"/>
<column name="password" type="varchar(255)"/>
<column name="email" type="varchar(255)"/>
</createTable>
<addPrimaryKey tableName="user"> columnNames="user" constraintName="user_pk">
Duplicate user occurred in userTable. The pk was removed because the user could have a duplicate name.
However, since we need to have the value of @Id, if we add the ID and set the autoIncrement, there will be a problem.
<dropPrimaryKey tableName="user"/>
<addColumn tableName="user">
<column name="id" type="BIGINT"/>
</addColumn>
<createSequence
incrementBy="1"
maxValue="9223372036854775807"
minValue="1"
startValue="1"
sequenceName="user_sequence"/>
Error Message
Reason: liquibase.exception.DatabaseException: ERROR: column "id" of relation "user" contains null values [Failed SQL: (0) ALTER TABLE "public"."user" ADD CONSTRAINT "PK_user" PRIMARY KEY ("id")]