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

Database diff not considering column length #594

Open
nfcunha opened this issue Oct 12, 2023 · 1 comment
Open

Database diff not considering column length #594

nfcunha opened this issue Oct 12, 2023 · 1 comment

Comments

@nfcunha
Copy link

nfcunha commented Oct 12, 2023

Hi everyone, I've encountered the following issue when running "diffChangelog" command in my project.

Currently, I have the following column in my database table:
image

It is a varchar, length 1000.

On the entity source code, the following mapping is done.

public class Expression {

    // stuff

    @Column(name = "glossary", length = 1000)
    private String glossary;

    // stuff

}

With the code above, the initial changelog was created correctly, specifying the length, etc.

However, if I change the "length" attribute to anything else, proceed to clean and build the classpath once again, and run the "diffChangelog" task, the newer changelog generates empty, without the supposed "ALTER TABLE" command.

If I rename the column, the current column is dropped and the new column is created correctly. Looking into past issues, issue #450 supposedly solved it.

I'm using the following configurations/versions. Am I missing something?

liquibase.properties:

referenceUrl=hibernate:spring:com.org.models?dialect=org.hibernate.dialect.PostgreSQLDialect
referenceDriver=liquibase.ext.hibernate.database.connection.HibernateDriver

build.gradle (plugin):

plugins {
	id 'application'
    id 'org.liquibase.gradle' version '2.1.0'
}

build.gradle (dependencies):

// Liquibase
    implementation ('org.liquibase:liquibase-core:4.24.0'){
        exclude group: 'org.yaml', module: 'snakeyaml'
    }
    // https://mvnrepository.com/artifact/org.liquibase.ext/liquibase-hibernate5
    implementation group: 'org.liquibase.ext', name: 'liquibase-hibernate5', version: '4.24.0'
    liquibaseRuntime 'org.liquibase.ext:liquibase-hibernate5:4.24.0'
    liquibaseRuntime 'org.liquibase:liquibase-core:4.24.0'
    liquibaseRuntime 'org.liquibase:liquibase-groovy-dsl:2.1.1'
    liquibaseRuntime 'org.postgresql:postgresql:42.6.0'
    liquibaseRuntime sourceSets.main.output
    liquibaseRuntime 'org.springframework:spring-beans'
    liquibaseRuntime 'org.springframework:spring-jdbc'
    liquibaseRuntime 'org.springframework:spring-context'
    liquibaseRuntime 'org.springframework:spring-orm'
    liquibaseRuntime 'info.picocli:picocli:4.6.1'

build.gradle (config):

final Instant buildTime = Instant.now();
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyddMMhhmmss")
        .withZone(ZoneId.systemDefault());
final String formattedBuildTime = formatter.format(buildTime);

liquibase {
    activities {
        main {
            changeLogFile "src/main/resources/db/changelogs/${formattedBuildTime}_changelog.sql"
            url "jdbc:postgresql://localhost:5432/my_db?currentSchema=my_schema"
            username "root"
            password "root"
        }
    }
}

Command being used to generate changelog:

gradle clean assemble diffChangelog

Thanks in advance.

@filipelautert
Copy link
Collaborator

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

@liquibot liquibot removed the TypeBug label Jun 26, 2024
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