Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diffChangeLog generates always an equal modifyDataType ChangeSet #499

Open
MKaluza1983 opened this issue Jun 14, 2023 · 1 comment
Open
Assignees

Comments

@MKaluza1983
Copy link

MKaluza1983 commented Jun 14, 2023

Hi, I am using the liquibase gradle plugin to generate the (diff)changeLog.
The first call of diffChangeLog worked (just a part of the whole code):

<changeSet author="XXX (generated)" id="1685451252740-4">
      <createTable tableName="booking">
          <column name="amount" type="INTEGER">
              <constraints nullable="false"/>
          </column>
      </createTable>
</changeSet>

Now I updated my database via updateSql. Until now everything worked great.

I didn't make any changes and started the diffChangeLog command and the result was:

<changeSet author="XXX (generated)" id="1686723018368-1">
      <modifyDataType columnName="amount" newDataType="int" tableName="booking"/>
</changeSet>

I performed an updateSql again because I thought it could be a type error (INTEGER vs int). The updateSql command has been executed (there was an entry in the changeLog table). I started the diffChangeLog again and there was the same modifyDataType in a new changeSet as above. How can I fix this? My gradle setup is:

import org.openapitools.generator.gradle.plugin.tasks.GenerateTask

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.1.0'
    id 'io.spring.dependency-management' version '1.1.0'
    id "org.openapi.generator" version "6.5.0"
    id 'org.liquibase.gradle' version '2.2.0'
}

group = 'de.test'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

ext {
    liquibaseChangeLogFile = './src/main/resources/liquibase/Main.xml'
    liquibaseDbUrl = 'jdbc:postgresql://localhost:5432/test'
    liquibaseDbUsername = 'username'
    liquibaseDbPassword = 'password'
    runList = project.hasProperty('runList') ? project.getProperty('runList') : 'main'
}

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
    liquibaseRuntime.extendsFrom runtime
}

liquibase {
    jvmArgs "-Duser.dir=$project.projectDir"
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-aop'
    implementation 'org.liquibase:liquibase-core'
    implementation 'javax.validation:validation-api:2.0.1.Final'
    implementation 'javax.annotation:javax.annotation-api:1.3.2'
    implementation "io.swagger.core.v3:swagger-annotations:2.2.9"
    implementation 'org.openapitools:jackson-databind-nullable:0.2.6'
    implementation 'org.mapstruct:mapstruct:1.5.5.Final'
    implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
    implementation 'com.google.code.findbugs:jsr305:3.0.2'

    compileOnly 'org.projectlombok:lombok'
    compileOnly 'javax.servlet:javax.servlet-api:4.0.1'
    runtimeOnly 'org.postgresql:postgresql'
    runtimeOnly 'io.micrometer:micrometer-registry-prometheus'

    annotationProcessor 'org.projectlombok:lombok'
    annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.5.Final'
...

    liquibaseRuntime 'org.springframework.boot:spring-boot-starter-data-jpa'
    liquibaseRuntime 'org.liquibase:liquibase-core'
    liquibaseRuntime 'org.liquibase:liquibase-groovy-dsl:3.0.3'
    liquibaseRuntime 'info.picocli:picocli:4.6.1'
    liquibaseRuntime 'org.liquibase.ext:liquibase-hibernate6:4.20.0'
    liquibaseRuntime 'org.postgresql:postgresql'
    liquibaseRuntime 'ch.qos.logback:logback-core'
    liquibaseRuntime 'ch.qos.logback:logback-classic'
    liquibaseRuntime 'jakarta.xml.bind:jakarta.xml.bind-api'

    liquibaseRuntime sourceSets.main.output
}

liquibase {
    activities {
        main {
            changeLogFile project.ext.liquibaseChangeLogFile
            url project.ext.liquibaseDbUrl
            username project.ext.liquibaseDbUsername
            password project.ext.liquibaseDbPassword
            referenceUrl 'hibernate:spring:de.test?dialect=org.hibernate.dialect.PostgreSQLDialect' +
                    '&hibernate.physical_naming_strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy' +
                    '&spring.jpa.hibernate.naming.implicit-strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy'
            logLevel "info"
        }
        diffMain {
            changeLogFile project.ext.liquibaseChangeLogFile
            url project.ext.liquibaseDbUrl
            username project.ext.liquibaseDbUsername
            password project.ext.liquibaseDbPassword
            referenceUrl 'hibernate:spring:de.test?dialect=org.hibernate.dialect.PostgreSQLDialect' +
                    '&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.CamelCaseToUnderscoresNamingStrategy' +
                    '&spring.jpa.hibernate.naming.implicit-strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy'
            logLevel "info"
        }
    }
    runList = project.ext.runList
}

jar {
    enabled = false
}

tasks.withType(JavaCompile).configureEach {
    options.encoding = 'UTF-8'
}

And a part of the java Entity is

@AllArgsConstructor
@Data
@SuperBuilder
@Entity
@EqualsAndHashCode(callSuper = true, exclude = {"id"})
@NoArgsConstructor
@Table(
        name = "booking"
)
@ToString(callSuper = true, exclude = {})
public class BookingEntity extends AbstractEntityBase {

    private static final String ENTITY = "booking";
    private static final String ENTITY_ID_SEQ = ENTITY + "_seq";

    @Id
    @SequenceGenerator(name = ENTITY_ID_SEQ, sequenceName = ENTITY_ID_SEQ, allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = ENTITY_ID_SEQ)
    private Long id;

    @Column(nullable = false, updatable = false)
    private int amount;
}

Thanks for helping!

@filipelautert
Copy link
Collaborator

@tati-qalified are you able to reproduce this one? thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants