Skip to content

Postgresql migrations using rename column cause compilation error e.g ALTER TABLE X RENAME COLUMN y TO Z #4879

@griffio

Description

@griffio

SQLDelight Version

2.0.*

Operating System

Any

Gradle Version

Any

Kotlin Version

Any

Dialect

Postgresql

AGP Version

No response

Describe the Bug

When using migration files (sqm) the rename column causes compilation error - happens in 2.0.0 and 2.0.1

ALTER TABLE Address RENAME COLUMN address TO address_1;

Work-around - rename query files first as the problem appears to be the error annotations erroring with a class cast exception
either ColumnDefMixin or SqlColumnName

Stacktrace

Postgresql
Cause: class app.cash.sqldelight.dialects.postgresql.grammar.psi.impl.PostgreSqlAlterTableRenameColumnImpl cannot be cast to class com.alecstrong.sql.psi.core.psi.mixins.ColumnDefMixin (app.cash.sqldelight.dialects.postgresql.grammar.psi.impl.PostgreSqlAlterTableRenameColumnImpl and com.alecstrong.sql.psi.core.psi.mixins.ColumnDefMixin are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @22a8bdc3)

Gradle Build Script

postgresql

sqldelight {
    databases {
        create("Sample") {
            deriveSchemaFromMigrations.set(true)
            migrationOutputDirectory = file("$buildDir/generated/migrations")
            migrationOutputFileFormat = ".sql" // Defaults to .sql
            packageName.set("griffio.queries")
            dialect(libs.sqldelight.postgresql.dialect)
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions