Uploaded image for project: 'Liquibase Core'
  1. CORE-2521

addAutoIncrement on Postgres generates invalid SQL when specific schema is used

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.4.1
    • Fix Version/s: 3.5.0
    • Component/s: Database Support
    • Environment:

      PostgreSQL

      Description

      The issue might be related to CORE-2114 Closed

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

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

      The corresponding SQL generated is this:

      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:

      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.

        Attachments

          Activity

            People

            • Reporter:
              Maximusya Yakimets Maksim
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: