liquibase-hibernate icon indicating copy to clipboard operation
liquibase-hibernate copied to clipboard

liquibase:generateChangeLog creates UUID properties as char(32) in changelog

Open ChexWarrior opened this issue 7 months ago • 1 comments

Hello,

Been working to integrate Liquibase with a Springboot project and while I have been able to run the generateChangeLog command via maven successfully I've noticed that all UUID properties I have specified in my entity classes all get translated to char(36) columns in the outputted changelog.

Command: ./mvnw liquibase:generateChangeLog -Dliquibase.verbose=true

Some output from the above command makes me think it is able to recognize the uuid attributes as UUIDs but something is getting lost during the generation of the changelog:

...
[INFO] Found column entity_id uuid
...

Sample Entity Snippet:

...
  @NotNull
  @Column(name = "entity_id")
  protected UUID id;
...

Sample changeset in generated changelog:

...
<createTable tableName="collection_revision">
            ...
            <column name="entity_id" type="char(36)">
                <constraints nullable="false"/>
            </column>
...

Manually replacing char(36) with uuid in the changelog and running an update against the db actually does seem to work when updating the actual database but I'd like to avoid such a manual workaround if possible. Is there anything anyone can think of which could be causing this? I saw in another issue that liquibase giving the column char(36) means it couldn't determine the type of database I was using but besides adding the dialect argument to the url above I don't know what else would indicate this to liquibase.

Some details:

  • Springboot version 3.3.1
  • Hibernate 6.5.2
  • Postgres DB backend
  • Liquibase Core 4.28.0

liquibase.properties file:

url=hibernate:spring:com.redacted.hidden?dialect=org.hibernate.dialect.PostgreSQLDialect&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
driver=liquibase.ext.hibernate.database.connection.HibernateDriver

Maven Plugin config:

            <plugin>
               <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>4.28.0</version>
                <configuration>
                    <propertyFile>liquibase.properties</propertyFile>
                    <outputChangeLogFile>src/main/resources/config/liquibase/master.xml</outputChangeLogFile>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.liquibase.ext</groupId>
                        <artifactId>liquibase-hibernate6</artifactId>
                        <version>4.28.0</version>
                    </dependency>
                    <dependency>
                        <groupId>org.liquibase</groupId>
                        <artifactId>liquibase-core</artifactId>
                        <version>4.28.0</version>
                    </dependency>
                    <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-validation</artifactId>
                        <version>3.3.1</version>
                    </dependency>
                    <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-jdbc</artifactId>
                        <version>3.3.1</version>
                    </dependency>
                    <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-data-jpa</artifactId>
                        <version>3.3.1</version>
                    </dependency>
                </dependencies>
            </plugin>

ChexWarrior avatar Jul 09 '24 18:07 ChexWarrior