Skip to content

Commit

Permalink
Fix failing sqlite VerifyMigrationTask with Hsql (#3380)
Browse files Browse the repository at this point in the history
Co-authored-by: hfhbd <hfhbd@users.noreply.github.com>
  • Loading branch information
hfhbd and hfhbd committed Jul 18, 2022
1 parent e00bb82 commit 7525999
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
Expand Up @@ -113,6 +113,7 @@ abstract class VerifyMigrationTask : SqlDelightWorkerTask() {
}

override fun execute() {
if (!environment.dialect.isSqlite) return
parameters.workingDirectory.get().asFile.deleteRecursively()

val catalog = createCurrentDb()
Expand Down
Expand Up @@ -27,6 +27,15 @@ class MigrationTest {
assertThat(output.output).contains("BUILD SUCCESSFUL")
}

@Test fun `verification disabled succeeds with hsql dialect`() {
val output = GradleRunner.create()
.withCommonConfiguration(File("src/test/verify-migration-disabled-no-errors"))
.withArguments("clean", "verifyMainDatabaseMigration", "--stacktrace")
.build()

assertThat(output.output).contains("BUILD SUCCESSFUL")
}

@Test fun `failing migration errors properly`() {
val output = GradleRunner.create()
.withCommonConfiguration(File("src/test/migration-failure"))
Expand Down
@@ -0,0 +1,21 @@
buildscript {
apply from: "${projectDir.absolutePath}/../buildscript.gradle"
}

apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'app.cash.sqldelight'

repositories {
maven {
url "file://${projectDir.absolutePath}/../../../../build/localMaven"
}
mavenCentral()
}

sqldelight {
Database {
packageName = "com.example"
dialect("app.cash.sqldelight:hsql-dialect:${app.cash.sqldelight.VersionKt.VERSION}")
verifyMigrations = false
}
}
@@ -0,0 +1,3 @@
apply from: "../settings.gradle"

rootProject.name = 'sqldelight-migrations'
@@ -0,0 +1,3 @@
CREATE TABLE foo(
bar BIGINT PRIMARY KEY AUTO_INCREMENT GENERATED ALWAYS AS IDENTITY
);

0 comments on commit 7525999

Please sign in to comment.