E52A Reproduction: Migration step silently dropped by elduffy · Pull Request #5902 · sqldelight/sqldelight · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@elduffy
C653
Copy link
@elduffy elduffy commented Aug 28, 2025

Issue: #5903

This PR reproduces a bug causing an entire migration step to be dropped from the generated migration code. This bug results from a specific build configuration:

  • Postgresql dialect
  • deriveSchemaFromMigrations=false
  • Unrecognized (but valid) SQL in an .sqm file such as ALTER INDEX.

I have reproduced by modifying the integration-postgresql-migrations to meet the criteria above. Rather than throwing a build error as expected, the code generator completes successfully but contains an empty migration step. Snippet of the output MyDatabaseImpl.kt:

      if (oldVersion <= 4 && newVersion > 4) {
        driver.execute(null, """
            |CREATE TABLE Orders
            |(
            |   id BIGINT PRIMARY KEY,
            |   sku VARCHAR(25) NOT NULL,
            |   quantity SMALLINT NOT NULL,
            |   price NUMERIC(10, 2) NOT NULL
            |)
            """.trimMargin(), 0)
      }
      if (oldVersion <= 5 && newVersion > 5) {
      }
      if (oldVersion <= 202304242140 && newVersion > 202304242140) {
        driver.execute(null, """
            |CREATE TABLE foo (
            |	id INT NOT NULL,
            |	PRIMARY KEY (id)
            |)
            """.trimMargin(), 0)
      }

Not only is the ALTER INDEX statement not applied, but other statement in V5__Order_alter.sqm is ignored as well. Tested by running

./gradlew test -p sqldelight-gradle-plugin --tests DialectIntegrationTests --rerun

@elduffy elduffy marked this pull request as draft August 28, 2025 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0