We're updating the issue view to help you get more done. 

addAutoIncrement on Postgres generates invalid SQL when specific schema is used

Description

The issue might be related to

When I try to make a column serial (i.e attach a sequence) like this:

1 <addAutoIncrement schemaName="items" tableName="item_instances" columnName="uid" />

The corresponding SQL generated is this:

1 2 3 4 CREATE SEQUENCE items.item_instances_uid_seq; ALTER TABLE items.item_instances ALTER COLUMN uid SET NOT NULL; ALTER TABLE items.item_instances ALTER COLUMN uid SET DEFAULT nextval('items.item_instances_uid_seq'); ALTER SEQUENCE items."items.item_instances_uid_seq" OWNED BY items.item_instances.uid;

Note the last statement contains sequence name

items."items.item_instances_uid_seq"

No wonder it fails with an error

Unexpected error running Liquibase: ERROR: relation "items.items.item_instances_uid_seq" does not exist [Failed SQL:ALTER SEQUENCE items."items.item_instances_uid_seq" OWNED BY items.item_instances.uid]

Manually written (copied from above and fixed) SQL runs just fine:

1 2 3 4 CREATE SEQUENCE items.item_instances_uid_seq; ALTER TABLE items.item_instances ALTER COLUMN uid SET NOT NULL; ALTER TABLE items.item_instances ALTER COLUMN uid SET DEFAULT nextval('items.item_instances_uid_seq'); ALTER SEQUENCE items.item_instances_uid_seq OWNED BY items.item_instances.uid;

Though I am not sure how to apply correct quoting and escaping of schema and sequence names in the above mentioned statements.

Environment

PostgreSQL

Status

Assignee

Unassigned

Reporter

Yakimets Maksim

Labels

None

Components

Fix versions

Affects versions

3.4.1

Priority

Major