liquibase / liquibase-hibernate

Liquibase Hibernate Integration
Apache License 2.0
272 stars 156 forks source link

liquibase-hibernate5 diffChangeLog Mode does not detect column type differences #140

Closed infprime closed 5 months ago

infprime commented 7 years ago

hi, With liquibase-hibernate5, the output xml does not include column type differences. But the normal "diff" detects and writes these differences normally in plain text format (not xml).

For example, the "diff" output says:

          type changed from 'varchar(255)' to 'INT(10)'

but the diffChangeLog output is empty

┆Issue is synchronized with this Jira Bug by Unito

joshuafc commented 4 years ago

I have the same issue, any news? My details:

group = 'com.cukak' version = '0.0.1-SNAPSHOT' sourceCompatibility = '1.8'

configurations { developmentOnly runtimeClasspath { extendsFrom developmentOnly } compileOnly { extendsFrom annotationProcessor } }

repositories { maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'} }

dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.liquibase:liquibase-core' implementation 'org.springframework.session:spring-session-core' compileOnly 'org.projectlombok:lombok' developmentOnly 'org.springframework.boot:spring-boot-devtools' runtimeOnly 'mysql:mysql-connector-java' annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' annotationProcessor 'org.projectlombok:lombok' testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' } testImplementation 'org.springframework.security:spring-security-test'

liquibaseRuntime 'org.liquibase:liquibase-core:3.8.8'
//liquibaseRuntime 'org.liquibase:liquibase-groovy-dsl:2.1.1'
liquibaseRuntime 'mysql:mysql-connector-java:8.0.19'
liquibaseRuntime 'org.liquibase.ext:liquibase-hibernate5:3.8'
liquibaseRuntime 'ch.qos.logback:logback-classic:1.2.3'
liquibaseRuntime 'javax.validation:validation-api:2.0.1.Final'
liquibaseRuntime 'org.yaml:snakeyaml:1.26'
liquibaseRuntime 'org.springframework.boot:spring-boot-starter-data-jpa:2.2.5.RELEASE'

liquibaseRuntime sourceSets.main.output

}

diff.dependsOn compileJava diffChangeLog.dependsOn compileJava

liquibase { activities { main { changeLogFile 'src/main/resources/db/changelog/changelog-master.xml' url 'jdbc:mysql://localhost:3306/db?serverTimezone=UTC' driver 'com.mysql.cj.jdbc.Driver' username 'Java' password 'Java@1234' referenceUrl 'hibernate:spring:com.cukak?dialect=org.hibernate.dialect.MySQL5Dialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy' //logLevel 'debug' } } runList = 'main' }

test { useJUnitPlatform() }


- changelog-master.xml (generated by diffChangeLog with empty mysql db):

<?xml version="1.1" encoding="UTF-8" standalone="no"?>


- User.java has modified

@Entity public class User { @Id int id;

@Column
String value; // "float value;" before modify

}

- `gradlew diff` output:

... Changed Column(s): HIBERNATE.user.id certainDataType changed from 'false' to 'null' order changed from 'null' to '1' type changed from 'integer' to 'INT(10)' HIBERNATE.user.value certainDataType changed from 'false' to 'null' order changed from 'null' to '2' type changed from 'varchar(255)' to 'FLOAT(12)' ...


- `gradlew diffChangeLog` output:

[liquibase.ext.hibernate.database.HibernateDatabase]: Found package com.cukak [liquibase.ext.hibernate.database.HibernateDatabase]: Using dialect org.hibernate.dialect.MySQL5Dialect [liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator]: Found table user [liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator]: Found table user [liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator]: Found table user [liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator]: Found primary key userPK [liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator]: Found column id integer [liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator]: Found column value varchar(255) [liquibase.diff.output.changelog.DiffToChangeLog$1]: src\main\resources\db\changelog\changelog-master.xml exists, appending [liquibase.diff.output.changelog.DiffToChangeLog$1]: No changes found, nothing to do [liquibase.integration.commandline.Main]: Liquibase command 'diffChangeLog' was executed successfully.

vincent-contreras commented 3 years ago

Hello, in my case, I have created the models but liquibase diff doesn't detect any models from my classes.

filipelautert commented 5 months ago

I remember seeing a fix for that around ~4.22.x , could you try again? If the problem still persists please reopen this ticket.