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

Specifying precision in fixed-precision integers fails when executing on Postgres #3661

Closed
burnumd opened this issue Jan 10, 2023 · 1 comment · Fixed by #4307
Closed

Specifying precision in fixed-precision integers fails when executing on Postgres #3661

burnumd opened this issue Jan 10, 2023 · 1 comment · Fixed by #4307
Labels
DBPostgres good first issue This issue is an easy starter project for new contributors. TypeBug

Comments

@burnumd
Copy link

burnumd commented Jan 10, 2023

Environment

Liquibase Version: 4.9.1

Liquibase Integration & Version: maven

Liquibase Extension(s) & Version: liquiibase-core 4.9.1

Database Vendor & Version: PostgreSQL 14.5.0

Operating System Type & Version: Mac OS 13.1

Infrastructure Type/Provider: n/a

Description

We have several old changesets which executed on H2 and mySQL without issue but there are change sets which declare a column type to be bigint(20). This parameter is deprecated and unused in modern versions of mySQL and Liquibase correctly ignores the parameter when executing against H2, but Liquibase generates invalid SQL against Postgres, which does not support the parameter at all.

Steps To Reproduce

databaseChangeLog:
  - changeSet:
      id: "create-revision-info-table"
      author: fraferna
      changes:
        - createTable:
            tableName: revinfo
            columns:
              - column:
                  name: id
                  type: int(11)
                  autoIncrement: true
                  constraints:
                    primaryKey: true
                    nullable: false
              - column:
                  name: timestamp
                  type: bigint(20)
                  defaultValueComputed: null

This change set is executed by Spring Data Liquibase when starting up a Spring Boot application. It executes successfully against H2 1.4.200 and mySQL 8.0.30-commercial. Against a Postgres 14.5.0 instance running in a Docker container on my local machine, it generates an error

Actual Behavior

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.LiquibaseException: liquibase.exception.MigrationFailedException: Migration failed for change set db/changelog/1.0/create-tables-1.0.yml::create-revision-info-table::fraferna:
     Reason: liquibase.exception.DatabaseException: ERROR: syntax error at or near "("
  Position: 102 [Failed SQL: (0) CREATE TABLE vrr01dev.revinfo (id INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL, timestamp BIGINT(20), CONSTRAINT revinfo_pkey PRIMARY KEY (id))]

Expected/Desired Behavior

I would expect Liquibase to generate a statement with timestamp BIGINT rather than including the invalid parameter to the column type on Postgres.

Screenshots (if appropriate)

If applicable, add screenshots to help explain your problem.

Additional Context

Add any other context about the problem here.

@FBurguer
Copy link

I was able to reproduce it and this behavior is not intended so we are adding it to the list of issues to fix. Thanks for the submittion!

@nvoxland nvoxland added the good first issue This issue is an easy starter project for new contributors. label Jan 25, 2023
@farion farion mentioned this issue May 24, 2023
3 tasks
filipelautert added a commit that referenced this issue Jul 5, 2023
Fixes 3661

Co-authored-by: filipe <flautert@liquibase.org>
Co-authored-by: rberezen <ruslan.berezenskyi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DBPostgres good first issue This issue is an easy starter project for new contributors. TypeBug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants