Skip to content

fix: Enable column type change migration for PostgreSQL #2441#2715

Open
shinseongsu wants to merge 1 commit intoJetBrains:mainfrom
shinseongsu:fix/2441-postgresql-column-type-change-migration
Open

fix: Enable column type change migration for PostgreSQL #2441#2715
shinseongsu wants to merge 1 commit intoJetBrains:mainfrom
shinseongsu:fix/2441-postgresql-column-type-change-migration

Conversation

@shinseongsu
Copy link
Copy Markdown

  • Add supportsColumnTypeChange = true to PostgreSQLDialect
  • Add test case for column type change migration
  • Update API declarations

Fixes #2441

Description

Summary of the change: Enable PostgreSQL to correctly detect and generate migration statements when a column's data type is modified.

Detailed description:

  • Why: The generateMigrationScript function for PostgreSQL was returning an empty file when only a column's data type was changed (e.g., from VARCHAR to TEXT). This occurred because supportsColumnTypeChange was not enabled in the PostgreSQLDialect class, causing the migration utility to skip type change detection entirely.

  • What:

    • Added supportsColumnTypeChange = true to the PostgreSQLDialect class.
    • This activates the existing column type change detection and migration statement generation logic that was already implemented but dormant for PostgreSQL.
  • How:

    • Overrode the supportsColumnTypeChange property in PostgreSQLDialect to return true.
    • The modifyColumn() implementation for PostgreSQL was already complete and correctly generates ALTER TABLE ... ALTER COLUMN ... TYPE ... statements.

Type of Change

Please mark the relevant options with an "X":

  • Bug fix
  • New feature
  • Documentation update

Updates/remove existing public API methods:

  • Is breaking change

Affected databases:

  • MariaDB
  • Mysql5
  • Mysql8
  • Oracle
  • Postgres
  • SqlServer
  • H2
  • SQLite

Checklist

  • Unit tests are in place
  • The build is green (including the Detekt check)
  • All public methods affected by my PR has up to date API docs
  • Documentation for my change is up to date

Related Issues

Fixes #2441

- Add supportsColumnTypeChange = true to PostgreSQLDialect
- Add test case for column type change migration
- Update API declarations

Fixes JetBrains#2441

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@bog-walk
Copy link
Copy Markdown
Member

Hi @shinseongsu Apologies for the delay on addressing this PR.

Everything you've mentioned makes sense. Since it seems modifyColumn() isn't being tested much at all for PostgreSQL, we just need to make sure that flipping this works for many more types. It shouldn't take long to run up more tests & see if which ones make the most sense to cover officially. I will get back to you shortly.

In the meantime, please consider changing this flag's value globally on your end, if you haven't already done so:

Database.connect(
    url = "...", 
    databaseConfig = DatabaseConfig {
         explicitDialect = object : PostgreSQLDialect() {
             override val supportsColumnTypeChange: Boolean = true
         }
    }
)

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

Successfully merging this pull request may close these issues.

generateMigrationScript ignores type change from varchar to text

2 participants