Skip to content

Problems with Diff functionality on PostgreSQL #217

@MaslovD

Description

@MaslovD

Once I create initial Diff change log, every following run of mvn clean install liquibase:diff generates a number of useless changeLog records.

For example, after initial run of mvn clean install liquibase:diff we the following file (which looks almost correct):
`databaseChangeLog:

  • changeSet:
    id: 1578360036411-1
    author: your_liquibase_username (generated)
    changes:
    • createTable:
      columns:
      • column:
        autoIncrement: true
        constraints:
        primaryKey: true
        primaryKeyName: rolesPK
        name: id
        type: BIGINT
      • column:
        constraints:
        nullable: false
        name: name
        type: VARCHAR(255)
        tableName: roles
  • changeSet:
    id: 1578360036411-2
    author: your_liquibase_username (generated)
    changes:
    • createTable:
      columns:
      • column:
        autoIncrement: true
        constraints:
        primaryKey: true
        primaryKeyName: usersPK
        name: id
        type: BIGINT
      • column:
        constraints:
        nullable: false
        name: email
        type: VARCHAR(255)
      • column:
        name: first_name
        type: VARCHAR(255)
      • column:
        name: last_name
        type: VARCHAR(255)
      • column:
        constraints:
        nullable: false
        name: password
        type: VARCHAR(255)
      • column:
        constraints:
        nullable: false
        name: username
        type: VARCHAR(255)
        tableName: users
  • changeSet:
    id: 1578360036411-3
    author: your_liquibase_username (generated)
    changes:
    • createTable:
      columns:
      • column:
        constraints:
        primaryKey: true
        name: user_id
        type: BIGINT
      • column:
        constraints:
        primaryKey: true
        name: role_id
        type: BIGINT
        tableName: users_roles
  • changeSet:
    id: 1578360036411-4
    author: your_liquibase_username (generated)
    changes:
    • addUniqueConstraint:
      columnNames: name
      constraintName: UC_ROLESNAME_COL
      tableName: roles
  • changeSet:
    id: 1578360036411-5
    author: your_liquibase_username (generated)
    changes:
    • addUniqueConstraint:
      columnNames: username
      constraintName: UC_USERSUSERNAME_COL
      tableName: users
  • changeSet:
    id: 1578360036411-6
    author: your_liquibase_username (generated)
    changes:
    • addForeignKeyConstraint:
      baseColumnNames: user_id
      baseTableName: users_roles
      constraintName: FK2o0jvgh89lemvvo17cbqvdxaa
      deferrable: false
      initiallyDeferred: false
      referencedColumnNames: id
      referencedTableName: users
      validate: true
  • changeSet:
    id: 1578360036411-7
    author: your_liquibase_username (generated)
    changes:
    • addForeignKeyConstraint:
      baseColumnNames: role_id
      baseTableName: users_roles
      constraintName: FKj6m8fwv7oqv74fcehir1a9ffy
      deferrable: false
      initiallyDeferred: false
      referencedColumnNames: id
      referencedTableName: roles
      validate: true
      `

after following run of mvn clean install liquibase:diff , I have new list of changes:

databaseChangeLog:

  • changeSet:
    id: 1578360244270-1
    author: your_liquibase_username (generated)
    changes:
    • dropUniqueConstraint:
      constraintName: UC_ROLESNAME_COL
      tableName: roles
  • changeSet:
    id: 1578360244270-2
    author: your_liquibase_username (generated)
    changes:
    • addUniqueConstraint:
      columnNames: name
      constraintName: UC_ROLESNAME_COL
      tableName: roles
  • changeSet:
    id: 1578360244270-3
    author: your_liquibase_username (generated)
    changes:
    • dropUniqueConstraint:
      constraintName: UC_USERSUSERNAME_COL
      tableName: users
  • changeSet:
    id: 1578360244270-4
    author: your_liquibase_username (generated)
    changes:
    • addUniqueConstraint:
      columnNames: username
      constraintName: UC_USERSUSERNAME_COL
      tableName: users

the build log is:
mvn clean compile liquibase:diff -DskipTests=true [INFO] Scanning for projects... [INFO] [INFO] ---------------------< ru.usharik:liquibase-demo >---------------------- [INFO] Building liquibase-demo 0.0.1-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ liquibase-demo --- [INFO] Deleting /Users/dmaslov/Sources/spring-liquibase-demo/target [INFO] [INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ liquibase-demo --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 2 resources [INFO] Copying 5 resources [INFO] [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ liquibase-demo --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 5 source files to /Users/dmaslov/Sources/spring-liquibase-demo/target/classes [INFO] [INFO] --- liquibase-maven-plugin:3.8.4:diff (default-cli) @ liquibase-demo --- [INFO] ------------------------------------------------------------------------ [INFO] No Liquibase Pro license key supplied. Please set liquibaseProLicenseKey on command line or in liquibase.properties to use Liquibase Pro features. [INFO] Liquibase Community 3.8.4 by Datical [INFO] Parsing Liquibase Properties File [INFO] File: /Users/dmaslov/Sources/spring-liquibase-demo/target/classes/liquibase-maven-plugin.properties [INFO] 'outputChangeLogFile' in properties file is not being used by this task. [INFO] 'ignoreClasspathPrefix' in properties file is not being used by this task. [INFO] ------------------------------------------------------------------------ [INFO] Starting Liquibase at Tue, 07 Jan 2020 04:24:02 MSK (version 3.8.4 #34 built at Fri Dec 20 06:33:43 UTC 2019) [INFO] Parsing Liquibase Properties File /Users/dmaslov/Sources/spring-liquibase-demo/target/classes/liquibase-maven-plugin.properties for changeLog parameters [INFO] Executing on Database: jdbc:postgresql://rumos0154:5432/facility_manager_service_dev?createDatabaseIfNotExist=true [WARNING] Namespace of the [javax.xml.bind.annotation.XmlSchema] annotation does not match [http://www.hibernate.org/xsd/orm/hbm]. Processing bindings will probably fail. [INFO] Reading hibernate configuration hibernate:spring:ru.usharik.liquibase.demo.persist.model?dialect=org.hibernate.dialect.PostgreSQL94Dialect&amp;hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&amp;hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy [INFO] Found package ru.usharik.liquibase.demo.persist.model [INFO] HHH000204: Processing PersistenceUnitInfo [ name: default ...] [INFO] HHH000412: Hibernate Core {5.0.10.Final} [INFO] HHH000206: hibernate.properties not found [INFO] HHH000021: Bytecode provider name : javassist [INFO] HCANN000001: Hibernate Commons Annotations {5.0.1.Final} [WARNING] HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections [WARNING] HHH000342: Could not obtain connection to query metadata : The application must supply JDBC connections [INFO] HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL94Dialect [INFO] HHH000422: Disabling contextual LOB creation as connection was null [INFO] HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType1426370c [INFO] Envers integration enabled? : true [INFO] HV000001: Hibernate Validator 6.0.17.Final [INFO] HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL94Dialect [INFO] Using dialect org.hibernate.dialect.PostgreSQL94Dialect [WARNING] HHH000342: Could not obtain connection to query metadata : No connection [INFO] HHH000422: Disabling contextual LOB creation as connection was null [INFO] HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType1426370c [INFO] Envers integration enabled? : true [INFO] Performing Diff on database postgres @ jdbc:postgresql://rumos0154:5432/facility_manager_service_dev?createDatabaseIfNotExist=true (Default Schema: public) [INFO] Found table roles [INFO] Found table roles [INFO] Found table users [INFO] Found table users [INFO] Found table users_roles [INFO] Found table users_roles [INFO] Found table users_roles [INFO] Found table users_roles [INFO] Found table roles [INFO] Found unique constraint UC_ROLESNAME_COL on roles(name) [INFO] Found primary key rolesPK [INFO] Found column id int8 [INFO] Found column name varchar(255) [INFO] Found table users [INFO] Found unique constraint UC_USERSUSERNAME_COL on users(username) [INFO] Found primary key usersPK [INFO] Found column id int8 [INFO] Found column email varchar(255) [INFO] Found column first_name varchar(255) [INFO] Found column last_name varchar(255) [INFO] Found column password varchar(255) [INFO] Found column username varchar(255) [INFO] Found table users_roles [INFO] Found primary key null [INFO] Found column user_id int8 [INFO] Found column role_id int8 [INFO] SELECT c.relname AS SEQUENCE_NAME, s.seqmin AS MIN_VALUE, s.seqmax AS MAX_VALUE, s.seqincrement AS INCREMENT_BY, s.seqcycle AS WILL_CYCLE, s.seqstart AS START_VALUE, s.seqcache AS CACHE_SIZE, pg_catalog.format_type(s.seqtypid, NULL) AS SEQ_TYPE FROM pg_class c JOIN pg_namespace ns on c.relnamespace = ns.oid JOIN pg_sequence s on c.oid = s.seqrelid WHERE c.relkind = 'S' AND ns.nspname = 'public' AND c.oid not in (select d.objid FROM pg_depend d where d.refobjsubid > 0) [INFO] select const.CONSTRAINT_NAME, COLUMN_NAME from information_schema.table_constraints const join information_schema.key_column_usage col on const.constraint_schema=col.constraint_schema and const.table_name=col.table_name and const.constraint_name=col.constraint_name where const.constraint_catalog='facility_manager_service_dev' and const.constraint_schema='public' and const.table_name='roles' and const.constraint_name='uc_rolesname_col'order by ordinal_position [INFO] select const.CONSTRAINT_NAME, COLUMN_NAME from information_schema.table_constraints const join information_schema.key_column_usage col on const.constraint_schema=col.constraint_schema and const.table_name=col.table_name and const.constraint_name=col.constraint_name where const.constraint_catalog='facility_manager_service_dev' and const.constraint_schema='public' and const.table_name='users' and const.constraint_name='uc_usersusername_col'order by ordinal_position [INFO] changeSets count: 4 [INFO] /Users/dmaslov/Sources/spring-liquibase-demo/src/main/resources/db/changelog/changes/db.changelog-20200107-012400918.yaml does not exist, creating and adding 4 changesets. [INFO] Differences written to Change Log File, /Users/dmaslov/Sources/spring-liquibase-demo/src/main/resources/db/changelog/changes/db.changelog-20200107-012400918.yaml [INFO] ------------------------------------------------------------------------ [INFO] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.209 s [INFO] Finished at: 2020-01-07T04:24:05+03:00 [INFO] ------------------------------------------------------------------------
Please

┆Issue is synchronized with this Jira Bug by Unito

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions