Trying to use addAutoIncrement (LiquiBase version 1.9.5) with PostgreSQL (8.4.0),
-
Auto increment the primary keys
I have the following error :
- Reason: liquibase.exception.JDBCException: Error executing SQL ALTER TABLE cp1_table ALTER COLUMN id SET DEFAULT 'cp1_table_id_seq':
Caused By: Error executing SQL ALTER TABLE cp1_table ALTER COLUMN id SET DEFAULT 'cp1_table_id_seq':
Caused By: ERROR: invalid input syntax for integer: "cp1_table_id_seq"
Should be:
- ALTER TABLE cp1_table ALTER COLUMN id SET DEFAULT NEXTVAL('cp1_table_id_seq')
A workaround is to use a native sql directive to define the changeSet, it works but …
-
Auto increment the primary keys (for PostgreSQL)
CREATE SEQUENCE cp1_table_id_seq;
ALTER TABLE cp1_table alter COLUMN id set default nextval('cp1_table_id_seq');
Remark: the autoIncrement attribute works correctly for a createTable.