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

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

Open
ChexWarrior opened this issue Jul 9, 2024 · 1 comment

Comments

@ChexWarrior
Copy link

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
Copy link
Author

ChexWarrior commented Jul 9, 2024

Got debugging with the maven command to work and I can see that my database is null when Liquibase checks the database type as mentioned here: #166 (comment)

Now to find out why that is...

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

1 participant