liquibase / liquibase-hibernate

Liquibase Hibernate Integration
Apache License 2.0
271 stars 157 forks source link

liquibase ignores envers tables postfix from org.liquibase.ext:liquibase-hibernate5:4.12.0 #460

Open anothergoodguy opened 1 year ago

anothergoodguy commented 1 year ago

Hi,

We are using liquibase gradle plugin and the audit table generration with custom postfix _version is working fine till liquibase-hibernate5:4.11.0, but it is using the default _aud from liquibase-hibernate5:4.12.0. The command we are using to generate the changelog is ./gradlew liquibaseDiffChangelog -PrunList=diffLog -Dorg.hibernate.envers.audit_table_suffix=_version -Dliquibase.diffTypes=data. Please advise if the generation parameters are wrong or if the new version needs new params.

Please be informed that I have tried till liquibase-hibernate5:4.19.0 with gradual increase of versions with no success.

Thanks in advance...

anothergoodguy commented 1 year ago

hi Team,

Any suggestions on this issue, please?

Thanks in advance...

filipelautert commented 6 months ago

Hi - there is an answer for a similar question in https://github.com/liquibase/liquibase-hibernate/issues/99#issuecomment-397455025 . Please reopen the issue if the problem still persists.

anothergoodguy commented 6 months ago

it still doesn't work even in liquibase-hibernate6 as well :(

my command is ./gradlew liquibaseDiffChangelog -PrunList=diffLog -Dorg.hibernate.envers.audit_table_suffix="_version" -Dhibernate.search.enabled=false -Dliquibase.diffTypes=data and my gradle config is

configurations {
    liquibaseRuntime.extendsFrom sourceSets.main.compileClasspath
}

dependencies {
  implementation "org.liquibase:liquibase-core"
  liquibaseRuntime "org.liquibase:liquibase-core"
  // Dependency required to parse options. Refer to https://github.com/liquibase/liquibase-gradle-plugin/tree/Release_2.2.0#news.
  liquibaseRuntime "info.picocli:picocli:4.7.5"
  liquibaseRuntime "com.mysql:mysql-connector-j"
  liquibaseRuntime "org.liquibase.ext:liquibase-hibernate6:${dependencyManagement.importedProperties['liquibase.version']}"
  // jhipster-needle-gradle-dependency - JHipster will add additional dependencies here
}

project.ext.diffChangelogFile = "src/main/resources/config/liquibase/changelog/" + new Date().format("yyyyMMddHHmmss") + "_changelog.xml"
if (!project.hasProperty("runList")) {
 project.ext.runList = "main"
}

liquibase {
  activities {
    main {
      driver "com.mysql.cj.jdbc.Driver"
      url "jdbc:mysql://<host>:<port>/my-db?useUnicode=true&characterEncoding=utf8&allowPublicKeyRetrieval=true&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true"
      username "troot"
      password "*****"
      changeLogFile "src/main/resources/config/liquibase/master.xml"
      referenceUrl "hibernate:spring:com.myapp.platform.domain?dialect=org.hibernate.dialect.MySQL8Dialect&hibernate.physical_naming_strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy"
      defaultSchemaName "my-db"
      logLevel "debug"
      classpath "src/main/resources/"
    }
    diffLog {
      driver "com.mysql.cj.jdbc.Driver"
      url "jdbc:mysql://<host>:<port>/my-db?useUnicode=true&characterEncoding=utf8&allowPublicKeyRetrieval=true&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true"
      username "troot"
      password "*****"
      changeLogFile project.ext.diffChangelogFile
      referenceUrl "hibernate:spring:com.myapp.platform.domain?dialect=org.hibernate.dialect.MySQL8Dialect&hibernate.physical_naming_strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy"
      defaultSchemaName "my-db"
      logLevel "debug"
      classpath "$buildDir/classes/java/main"
      excludeObjects "oauth_access_token, oauth_approvals, oauth_client_details, oauth_client_token, oauth_code, oauth_refresh_token"
    }
  }

  runList = project.ext.runList
}

liquibaseDiff.dependsOn compileJava
liquibaseDiffChangelog.dependsOn compileJava

ext {
  if (project.hasProperty("no-liquibase")) {
    springProfiles += ",no-liquibase"
  }
}
anothergoodguy commented 6 months ago

not sure, why but I cant see an option to reopen this issue

anothergoodguy commented 6 months ago

no difference observed on this context for both these commands:

  1. ./gradlew liquibaseDiffChangelog -PrunList=diffLog -Dorg.hibernate.envers.audit_table_suffix="_version" -Dhibernate.search.enabled=false -Dliquibase.diffTypes=data
  2. ./gradlew liquibaseDiffChangelog -PrunList=diffLog -Dorg.hibernate.envers.audit_table_suffix="_version" -Dhibernate.search.enabled=false -Dliquibase.diffTypes=data -Dorg.hibernate.envers.global_with_modified_flag=true
gdenchev commented 3 months ago

Had the same problem today.

Looked at the source code: https://github.com/search?q=repo%3Aliquibase%2Fliquibase-hibernate%20AUDIT_TABLE_SUFFIX&type=code

Saw that the code searches for the audit table suffix setting in the connection URL.

Tried with the following in my liquibase.properties: referenceUrl=hibernate:spring:[your_model_package]?dialect=org.hibernate.dialect.PostgreSQLDialect&org.hibernate.envers.audit_table_suffix=_aud

Seemed to work for me, please have a try and hopefully it will work for you :)