diff --git a/exposed-migration/src/main/kotlin/MigrationUtils.kt b/exposed-migration/src/main/kotlin/MigrationUtils.kt index 0642d9f85c..98402b6a3a 100644 --- a/exposed-migration/src/main/kotlin/MigrationUtils.kt +++ b/exposed-migration/src/main/kotlin/MigrationUtils.kt @@ -82,7 +82,7 @@ object MigrationUtils { val modifyTablesStatements = logTimeSpent("Checking mapping consistence", withLogs) { mappingConsistenceRequiredStatements( - tables = tables, + tables = tablesToAlter.toTypedArray(), withLogs ).filter { it !in (createStatements + alterStatements) } } diff --git a/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/ddl/DatabaseMigrationTests.kt b/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/ddl/DatabaseMigrationTests.kt index baaf76e2b9..994a8e352f 100644 --- a/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/ddl/DatabaseMigrationTests.kt +++ b/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/ddl/DatabaseMigrationTests.kt @@ -133,6 +133,23 @@ class DatabaseMigrationTests : DatabaseTestsBase() { } } + @Test + fun testCreateStatementsGeneratedForTablesThatDoNotExist() { + val tester = object : Table("tester") { + val bar = char("bar") + } + + withDb { + val statements = MigrationUtils.statementsRequiredForDatabaseMigration(tester, withLogs = false) + assertEquals(1, statements.size) + assertEquals( + "CREATE TABLE ${addIfNotExistsIfSupported()}${tester.nameInDatabaseCase()} " + + "(${"bar".inProperCase()} CHAR NOT NULL)", + statements.first() + ) + } + } + @Test fun testDropUnmappedColumnsStatementsIdentical() { val t1 = object : Table("foo") {