From 7c3df2f81ae637f2ad22bd40ea31fd5682f95a36 Mon Sep 17 00:00:00 2001 From: Jocelyne <38375996+joc-a@users.noreply.github.com> Date: Mon, 12 Aug 2024 12:44:12 +0300 Subject: [PATCH] refactor!: Move `statementsRequiredForDatabaseMigration` function from `SchemaUtils` to `MigrationUtils` (#2195) --- exposed-core/api/exposed-core.api | 2 - .../org/jetbrains/exposed/sql/SchemaUtils.kt | 163 --------------- exposed-java-time/build.gradle.kts | 1 + .../org/jetbrains/exposed/JavaTimeTests.kt | 2 +- exposed-kotlin-datetime/build.gradle.kts | 1 + .../sql/kotlin/datetime/KotlinTimeTests.kt | 2 +- exposed-migration/api/exposed-migration.api | 2 + .../src/main/kotlin/MigrationUtils.kt | 187 +++++++++++++++++- .../shared/ddl/DatabaseMigrationTests.kt | 16 +- 9 files changed, 200 insertions(+), 176 deletions(-) diff --git a/exposed-core/api/exposed-core.api b/exposed-core/api/exposed-core.api index e03faf8b79..e0bf26506a 100644 --- a/exposed-core/api/exposed-core.api +++ b/exposed-core/api/exposed-core.api @@ -2114,8 +2114,6 @@ public final class org/jetbrains/exposed/sql/SchemaUtils { public final fun setSchema (Lorg/jetbrains/exposed/sql/Schema;Z)V public static synthetic fun setSchema$default (Lorg/jetbrains/exposed/sql/SchemaUtils;Lorg/jetbrains/exposed/sql/Schema;ZILjava/lang/Object;)V public final fun sortTablesByReferences (Ljava/lang/Iterable;)Ljava/util/List; - public final fun statementsRequiredForDatabaseMigration ([Lorg/jetbrains/exposed/sql/Table;Z)Ljava/util/List; - public static synthetic fun statementsRequiredForDatabaseMigration$default (Lorg/jetbrains/exposed/sql/SchemaUtils;[Lorg/jetbrains/exposed/sql/Table;ZILjava/lang/Object;)Ljava/util/List; public final fun statementsRequiredToActualizeScheme ([Lorg/jetbrains/exposed/sql/Table;Z)Ljava/util/List; public static synthetic fun statementsRequiredToActualizeScheme$default (Lorg/jetbrains/exposed/sql/SchemaUtils;[Lorg/jetbrains/exposed/sql/Table;ZILjava/lang/Object;)Ljava/util/List; public final fun withDataBaseLock (Lorg/jetbrains/exposed/sql/Transaction;Lkotlin/jvm/functions/Function0;)V diff --git a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/SchemaUtils.kt b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/SchemaUtils.kt index 6687e30db8..7c677f23a6 100644 --- a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/SchemaUtils.kt +++ b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/SchemaUtils.kt @@ -613,17 +613,6 @@ object SchemaUtils { return checkMissingAndUnmappedIndices(tables = tables, withLogs).flatMap { it.createStatement() } } - /** - * Log Exposed table mappings <-> real database mapping problems and returns DDL Statements to fix them, including - * DROP/DELETE statements (unlike [checkMappingConsistence]) - */ - private fun mappingConsistenceRequiredStatements(vararg tables: Table, withLogs: Boolean = true): List { - return checkMissingIndices(tables = tables, withLogs).flatMap { it.createStatement() } + - checkUnmappedIndices(tables = tables, withLogs).flatMap { it.dropStatement() } + - checkExcessiveForeignKeyConstraints(tables = tables, withLogs).flatMap { it.dropStatement() } + - checkExcessiveIndices(tables = tables, withLogs).flatMap { it.dropStatement() } - } - /** * Checks all [tables] for any that have more than one defined index and logs the findings. If found, this function * also logs the SQL statements that can be used to drop these indices. @@ -779,158 +768,6 @@ object SchemaUtils { return toCreate.toList() } - /** - * Checks all [tables] for any that have indices that are missing in the database but are defined in the code. If - * found, this function also logs the SQL statements that can be used to create these indices. - * - * @return List of indices that are missing and can be created. - */ - private fun checkMissingIndices(vararg tables: Table, withLogs: Boolean): List { - fun Collection.log(mainMessage: String) { - if (withLogs && isNotEmpty()) { - exposedLogger.warn(joinToString(prefix = "$mainMessage\n\t\t", separator = "\n\t\t")) - } - } - - val fKeyConstraints = currentDialect.columnConstraints(*tables).keys - val existingIndices = currentDialect.existingIndices(*tables) - - fun List.filterForeignKeys() = if (currentDialect is MysqlDialect) { - filterNot { it.table to LinkedHashSet(it.columns) in fKeyConstraints } - } else { - this - } - - // SQLite: indices whose names start with "sqlite_" are meant for internal use - fun List.filterInternalIndices() = if (currentDialect is SQLiteDialect) { - filter { !it.indexName.startsWith("sqlite_") } - } else { - this - } - - fun Table.existingIndices() = existingIndices[this].orEmpty().filterForeignKeys().filterInternalIndices() - - fun Table.mappedIndices() = this.indices.filterForeignKeys().filterInternalIndices() - - val missingIndices = HashSet() - val nameDiffers = HashSet() - - tables.forEach { table -> - val existingTableIndices = table.existingIndices() - val mappedIndices = table.mappedIndices() - - for (index in existingTableIndices) { - val mappedIndex = mappedIndices.firstOrNull { it.onlyNameDiffer(index) } ?: continue - if (withLogs) { - exposedLogger.info( - "Index on table '${table.tableName}' differs only in name: in db ${index.indexName} -> in mapping ${mappedIndex.indexName}" - ) - } - nameDiffers.add(index) - nameDiffers.add(mappedIndex) - } - - missingIndices.addAll(mappedIndices.subtract(existingTableIndices)) - } - - val toCreate = missingIndices.subtract(nameDiffers) - toCreate.log("Indices missed from database (will be created):") - return toCreate.toList() - } - - /** - * Checks all [tables] for any that have indices that exist in the database but are not mapped in the code. If - * found, this function also logs the SQL statements that can be used to drop these indices. - * - * @return List of indices that are unmapped and can be dropped. - */ - private fun checkUnmappedIndices(vararg tables: Table, withLogs: Boolean): List { - fun Collection.log(mainMessage: String) { - if (withLogs && isNotEmpty()) { - exposedLogger.warn(joinToString(prefix = "$mainMessage\n\t\t", separator = "\n\t\t")) - } - } - - val foreignKeyConstraints = currentDialect.columnConstraints(*tables).keys - val existingIndices = currentDialect.existingIndices(*tables) - - fun List.filterForeignKeys() = if (currentDialect is MysqlDialect) { - filterNot { it.table to LinkedHashSet(it.columns) in foreignKeyConstraints } - } else { - this - } - - // SQLite: indices whose names start with "sqlite_" are meant for internal use - fun List.filterInternalIndices() = if (currentDialect is SQLiteDialect) { - filter { !it.indexName.startsWith("sqlite_") } - } else { - this - } - - fun Table.existingIndices() = existingIndices[this].orEmpty().filterForeignKeys().filterInternalIndices() - - fun Table.mappedIndices() = this.indices.filterForeignKeys().filterInternalIndices() - - val unmappedIndices = HashMap>() - val nameDiffers = HashSet() - - tables.forEach { table -> - val existingTableIndices = table.existingIndices() - val mappedIndices = table.mappedIndices() - - for (index in existingTableIndices) { - val mappedIndex = mappedIndices.firstOrNull { it.onlyNameDiffer(index) } ?: continue - nameDiffers.add(index) - nameDiffers.add(mappedIndex) - } - - unmappedIndices.getOrPut(table.nameInDatabaseCase()) { - hashSetOf() - }.addAll(existingTableIndices.subtract(mappedIndices)) - } - - val toDrop = mutableSetOf() - unmappedIndices.forEach { (name, indices) -> - toDrop.addAll( - indices.subtract(nameDiffers).also { - it.log("Indices exist in database and not mapped in code on class '$name':") - } - ) - } - return toDrop.toList() - } - - /** - * Returns the SQL statements that need to be executed to make the existing database schema compatible with - * the table objects defined using Exposed. Unlike [statementsRequiredToActualizeScheme], DROP/DELETE statements are - * included. - * - * **Note:** Some dialects, like SQLite, do not support `ALTER TABLE ADD COLUMN` syntax completely, - * which restricts the behavior when adding some missing columns. Please check the documentation. - * - * By default, a description for each intermediate step, as well as its execution time, is logged at the INFO level. - * This can be disabled by setting [withLogs] to `false`. - */ - fun statementsRequiredForDatabaseMigration(vararg tables: Table, withLogs: Boolean = true): List { - val (tablesToCreate, tablesToAlter) = tables.partition { !it.exists() } - val createStatements = logTimeSpent("Preparing create tables statements", withLogs) { - createStatements(tables = tablesToCreate.toTypedArray()) - } - val alterStatements = logTimeSpent("Preparing alter table statements", withLogs) { - addMissingColumnsStatements(tables = tablesToAlter.toTypedArray(), withLogs) - } - - val modifyTablesStatements = logTimeSpent("Checking mapping consistence", withLogs) { - mappingConsistenceRequiredStatements( - tables = tables, - withLogs - ).filter { it !in (createStatements + alterStatements) } - } - - val allStatements = createStatements + alterStatements + modifyTablesStatements - return allStatements - } - /** * Creates table with name "busy" (if not present) and single column to be used as "synchronization" point. Table wont be dropped after execution. * diff --git a/exposed-java-time/build.gradle.kts b/exposed-java-time/build.gradle.kts index d8c47c5d8e..20c47c0fb8 100644 --- a/exposed-java-time/build.gradle.kts +++ b/exposed-java-time/build.gradle.kts @@ -20,6 +20,7 @@ dependencies { testImplementation(project(":exposed-dao")) testImplementation(project(":exposed-tests")) testImplementation(project(":exposed-json")) + testImplementation(project(":exposed-migration")) testImplementation(libs.junit) testImplementation(kotlin("test-junit")) } diff --git a/exposed-java-time/src/test/kotlin/org/jetbrains/exposed/JavaTimeTests.kt b/exposed-java-time/src/test/kotlin/org/jetbrains/exposed/JavaTimeTests.kt index e2c27734f1..4658d0d0cf 100644 --- a/exposed-java-time/src/test/kotlin/org/jetbrains/exposed/JavaTimeTests.kt +++ b/exposed-java-time/src/test/kotlin/org/jetbrains/exposed/JavaTimeTests.kt @@ -601,7 +601,7 @@ class JavaTimeTests : DatabaseTestsBase() { val date: Column = date("date").index().defaultExpression(CurrentDate) } withTables(testTable) { - val statements = SchemaUtils.statementsRequiredForDatabaseMigration(testTable) + val statements = MigrationUtils.statementsRequiredForDatabaseMigration(testTable) assertTrue(statements.isEmpty()) } } diff --git a/exposed-kotlin-datetime/build.gradle.kts b/exposed-kotlin-datetime/build.gradle.kts index f56905581f..e57d330032 100644 --- a/exposed-kotlin-datetime/build.gradle.kts +++ b/exposed-kotlin-datetime/build.gradle.kts @@ -22,6 +22,7 @@ dependencies { testImplementation(project(":exposed-dao")) testImplementation(project(":exposed-tests")) testImplementation(project(":exposed-json")) + testImplementation(project(":exposed-migration")) testImplementation(libs.junit) testImplementation(kotlin("test-junit")) } diff --git a/exposed-kotlin-datetime/src/test/kotlin/org/jetbrains/exposed/sql/kotlin/datetime/KotlinTimeTests.kt b/exposed-kotlin-datetime/src/test/kotlin/org/jetbrains/exposed/sql/kotlin/datetime/KotlinTimeTests.kt index 47dcd063ea..da44e298e7 100644 --- a/exposed-kotlin-datetime/src/test/kotlin/org/jetbrains/exposed/sql/kotlin/datetime/KotlinTimeTests.kt +++ b/exposed-kotlin-datetime/src/test/kotlin/org/jetbrains/exposed/sql/kotlin/datetime/KotlinTimeTests.kt @@ -618,7 +618,7 @@ class KotlinTimeTests : DatabaseTestsBase() { val date: Column = date("date").index().defaultExpression(CurrentDate) } withTables(testTable) { - val statements = SchemaUtils.statementsRequiredForDatabaseMigration(testTable) + val statements = MigrationUtils.statementsRequiredForDatabaseMigration(testTable) assertTrue(statements.isEmpty()) } } diff --git a/exposed-migration/api/exposed-migration.api b/exposed-migration/api/exposed-migration.api index ab41b6df6b..d351ae4656 100644 --- a/exposed-migration/api/exposed-migration.api +++ b/exposed-migration/api/exposed-migration.api @@ -2,5 +2,7 @@ public final class MigrationUtils { public static final field INSTANCE LMigrationUtils; public final fun generateMigrationScript ([Lorg/jetbrains/exposed/sql/Table;Ljava/lang/String;Ljava/lang/String;Z)Ljava/io/File; public static synthetic fun generateMigrationScript$default (LMigrationUtils;[Lorg/jetbrains/exposed/sql/Table;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/io/File; + public final fun statementsRequiredForDatabaseMigration ([Lorg/jetbrains/exposed/sql/Table;Z)Ljava/util/List; + public static synthetic fun statementsRequiredForDatabaseMigration$default (LMigrationUtils;[Lorg/jetbrains/exposed/sql/Table;ZILjava/lang/Object;)Ljava/util/List; } diff --git a/exposed-migration/src/main/kotlin/MigrationUtils.kt b/exposed-migration/src/main/kotlin/MigrationUtils.kt index 579715d453..5b7681d126 100644 --- a/exposed-migration/src/main/kotlin/MigrationUtils.kt +++ b/exposed-migration/src/main/kotlin/MigrationUtils.kt @@ -1,6 +1,17 @@ import org.jetbrains.exposed.sql.ExperimentalDatabaseMigrationApi -import org.jetbrains.exposed.sql.SchemaUtils.statementsRequiredForDatabaseMigration +import org.jetbrains.exposed.sql.Index +import org.jetbrains.exposed.sql.SchemaUtils.addMissingColumnsStatements +import org.jetbrains.exposed.sql.SchemaUtils.checkExcessiveForeignKeyConstraints +import org.jetbrains.exposed.sql.SchemaUtils.checkExcessiveIndices +import org.jetbrains.exposed.sql.SchemaUtils.checkMappingConsistence +import org.jetbrains.exposed.sql.SchemaUtils.createStatements +import org.jetbrains.exposed.sql.SchemaUtils.statementsRequiredToActualizeScheme import org.jetbrains.exposed.sql.Table +import org.jetbrains.exposed.sql.exists +import org.jetbrains.exposed.sql.exposedLogger +import org.jetbrains.exposed.sql.vendors.MysqlDialect +import org.jetbrains.exposed.sql.vendors.SQLiteDialect +import org.jetbrains.exposed.sql.vendors.currentDialect import java.io.File object MigrationUtils { @@ -41,4 +52,178 @@ object MigrationUtils { return migrationScript } + + /** + * Returns the SQL statements that need to be executed to make the existing database schema compatible with + * the table objects defined using Exposed. Unlike [statementsRequiredToActualizeScheme], DROP/DELETE statements are + * included. + * + * **Note:** Some dialects, like SQLite, do not support `ALTER TABLE ADD COLUMN` syntax completely, + * which restricts the behavior when adding some missing columns. Please check the documentation. + * + * By default, a description for each intermediate step, as well as its execution time, is logged at the INFO level. + * This can be disabled by setting [withLogs] to `false`. + */ + fun statementsRequiredForDatabaseMigration(vararg tables: Table, withLogs: Boolean = true): List { + val (tablesToCreate, tablesToAlter) = tables.partition { !it.exists() } + val createStatements = logTimeSpent("Preparing create tables statements", withLogs) { + createStatements(tables = tablesToCreate.toTypedArray()) + } + val alterStatements = logTimeSpent("Preparing alter table statements", withLogs) { + addMissingColumnsStatements(tables = tablesToAlter.toTypedArray(), withLogs) + } + + val modifyTablesStatements = logTimeSpent("Checking mapping consistence", withLogs) { + mappingConsistenceRequiredStatements( + tables = tables, + withLogs + ).filter { it !in (createStatements + alterStatements) } + } + + val allStatements = createStatements + alterStatements + modifyTablesStatements + return allStatements + } + + /** + * Log Exposed table mappings <-> real database mapping problems and returns DDL Statements to fix them, including + * DROP/DELETE statements (unlike [checkMappingConsistence]) + */ + private fun mappingConsistenceRequiredStatements(vararg tables: Table, withLogs: Boolean = true): List { + return checkMissingIndices(tables = tables, withLogs).flatMap { it.createStatement() } + + checkUnmappedIndices(tables = tables, withLogs).flatMap { it.dropStatement() } + + checkExcessiveForeignKeyConstraints(tables = tables, withLogs).flatMap { it.dropStatement() } + + checkExcessiveIndices(tables = tables, withLogs).flatMap { it.dropStatement() } + } + + /** + * Checks all [tables] for any that have indices that are missing in the database but are defined in the code. If + * found, this function also logs the SQL statements that can be used to create these indices. + * + * @return List of indices that are missing and can be created. + */ + private fun checkMissingIndices(vararg tables: Table, withLogs: Boolean): List { + fun Collection.log(mainMessage: String) { + if (withLogs && isNotEmpty()) { + exposedLogger.warn(joinToString(prefix = "$mainMessage\n\t\t", separator = "\n\t\t")) + } + } + + val fKeyConstraints = currentDialect.columnConstraints(*tables).keys + val existingIndices = currentDialect.existingIndices(*tables) + + fun List.filterForeignKeys() = if (currentDialect is MysqlDialect) { + filterNot { it.table to LinkedHashSet(it.columns) in fKeyConstraints } + } else { + this + } + + // SQLite: indices whose names start with "sqlite_" are meant for internal use + fun List.filterInternalIndices() = if (currentDialect is SQLiteDialect) { + filter { !it.indexName.startsWith("sqlite_") } + } else { + this + } + + fun Table.existingIndices() = existingIndices[this].orEmpty().filterForeignKeys().filterInternalIndices() + + fun Table.mappedIndices() = this.indices.filterForeignKeys().filterInternalIndices() + + val missingIndices = HashSet() + val nameDiffers = HashSet() + + tables.forEach { table -> + val existingTableIndices = table.existingIndices() + val mappedIndices = table.mappedIndices() + + for (index in existingTableIndices) { + val mappedIndex = mappedIndices.firstOrNull { it.onlyNameDiffer(index) } ?: continue + if (withLogs) { + exposedLogger.info( + "Index on table '${table.tableName}' differs only in name: in db ${index.indexName} -> in mapping ${mappedIndex.indexName}" + ) + } + nameDiffers.add(index) + nameDiffers.add(mappedIndex) + } + + missingIndices.addAll(mappedIndices.subtract(existingTableIndices)) + } + + val toCreate = missingIndices.subtract(nameDiffers) + toCreate.log("Indices missed from database (will be created):") + return toCreate.toList() + } + + /** + * Checks all [tables] for any that have indices that exist in the database but are not mapped in the code. If + * found, this function also logs the SQL statements that can be used to drop these indices. + * + * @return List of indices that are unmapped and can be dropped. + */ + private fun checkUnmappedIndices(vararg tables: Table, withLogs: Boolean): List { + fun Collection.log(mainMessage: String) { + if (withLogs && isNotEmpty()) { + exposedLogger.warn(joinToString(prefix = "$mainMessage\n\t\t", separator = "\n\t\t")) + } + } + + val foreignKeyConstraints = currentDialect.columnConstraints(*tables).keys + val existingIndices = currentDialect.existingIndices(*tables) + + fun List.filterForeignKeys() = if (currentDialect is MysqlDialect) { + filterNot { it.table to LinkedHashSet(it.columns) in foreignKeyConstraints } + } else { + this + } + + // SQLite: indices whose names start with "sqlite_" are meant for internal use + fun List.filterInternalIndices() = if (currentDialect is SQLiteDialect) { + filter { !it.indexName.startsWith("sqlite_") } + } else { + this + } + + fun Table.existingIndices() = existingIndices[this].orEmpty().filterForeignKeys().filterInternalIndices() + + fun Table.mappedIndices() = this.indices.filterForeignKeys().filterInternalIndices() + + val unmappedIndices = HashMap>() + val nameDiffers = HashSet() + + tables.forEach { table -> + val existingTableIndices = table.existingIndices() + val mappedIndices = table.mappedIndices() + + for (index in existingTableIndices) { + val mappedIndex = mappedIndices.firstOrNull { it.onlyNameDiffer(index) } ?: continue + nameDiffers.add(index) + nameDiffers.add(mappedIndex) + } + + unmappedIndices.getOrPut(table.nameInDatabaseCase()) { + hashSetOf() + }.addAll(existingTableIndices.subtract(mappedIndices)) + } + + val toDrop = mutableSetOf() + unmappedIndices.forEach { (name, indices) -> + toDrop.addAll( + indices.subtract(nameDiffers).also { + it.log("Indices exist in database and not mapped in code on class '$name':") + } + ) + } + return toDrop.toList() + } + + private inline fun logTimeSpent(message: String, withLogs: Boolean, block: () -> R): R { + return if (withLogs) { + val start = System.currentTimeMillis() + val answer = block() + exposedLogger.info(message + " took " + (System.currentTimeMillis() - start) + "ms") + answer + } else { + block() + } + } } 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 399aee65b6..d1ed416716 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 @@ -44,7 +44,7 @@ class DatabaseMigrationTests : DatabaseTestsBase() { assertTrue(script.exists()) assertEquals("src/test/resources/$scriptName.sql", script.path) - val expectedStatements: List = SchemaUtils.statementsRequiredForDatabaseMigration(singlePKTable) + val expectedStatements: List = MigrationUtils.statementsRequiredForDatabaseMigration(singlePKTable) assertEquals(1, expectedStatements.size) val fileStatements: List = script.bufferedReader().readLines().map { it.trimEnd(';') } @@ -80,7 +80,7 @@ class DatabaseMigrationTests : DatabaseTestsBase() { // Create initial script val initialScript = File("$directory/$name.sql") initialScript.createNewFile() - val statements = SchemaUtils.statementsRequiredForDatabaseMigration(noPKTable) + val statements = MigrationUtils.statementsRequiredForDatabaseMigration(noPKTable) statements.forEach { initialScript.appendText(it) } @@ -88,7 +88,7 @@ class DatabaseMigrationTests : DatabaseTestsBase() { // Generate script with the same name of initial script val newScript = MigrationUtils.generateMigrationScript(singlePKTable, scriptDirectory = directory, scriptName = name) - val expectedStatements: List = SchemaUtils.statementsRequiredForDatabaseMigration(singlePKTable) + val expectedStatements: List = MigrationUtils.statementsRequiredForDatabaseMigration(singlePKTable) assertEquals(1, expectedStatements.size) val fileStatements: List = newScript.bufferedReader().readLines().map { it.trimEnd(';') } @@ -131,7 +131,7 @@ class DatabaseMigrationTests : DatabaseTestsBase() { assertNull(primaryKey) val expected = "ALTER TABLE ${tableName.inProperCase()} ADD PRIMARY KEY (${noPKTable.bar.nameInDatabaseCase()})" - val statements = SchemaUtils.statementsRequiredForDatabaseMigration(singlePKTable) + val statements = MigrationUtils.statementsRequiredForDatabaseMigration(singlePKTable) assertEquals(expected, statements.single()) } finally { SchemaUtils.drop(noPKTable) @@ -157,7 +157,7 @@ class DatabaseMigrationTests : DatabaseTestsBase() { } SchemaUtils.create(table) - val actual = SchemaUtils.statementsRequiredForDatabaseMigration(table) + val actual = MigrationUtils.statementsRequiredForDatabaseMigration(table) assertEqualLists(emptyList(), actual) } finally { SchemaUtils.drop(table) @@ -177,7 +177,7 @@ class DatabaseMigrationTests : DatabaseTestsBase() { SchemaUtils.create(quotedTable) assertTrue(quotedTable.exists()) - val statements = SchemaUtils.statementsRequiredForDatabaseMigration(quotedTable) + val statements = MigrationUtils.statementsRequiredForDatabaseMigration(quotedTable) assertTrue(statements.isEmpty()) } finally { SchemaUtils.drop(quotedTable) @@ -210,7 +210,7 @@ class DatabaseMigrationTests : DatabaseTestsBase() { SchemaUtils.create(testTableWithTwoIndices) assertTrue(testTableWithTwoIndices.exists()) - val statements = SchemaUtils.statementsRequiredForDatabaseMigration(testTableWithOneIndex) + val statements = MigrationUtils.statementsRequiredForDatabaseMigration(testTableWithOneIndex) assertEquals(1, statements.size) } finally { SchemaUtils.drop(testTableWithTwoIndices) @@ -240,7 +240,7 @@ class DatabaseMigrationTests : DatabaseTestsBase() { SchemaUtils.create(testTableWithIndex) assertTrue(testTableWithIndex.exists()) - val statements = SchemaUtils.statementsRequiredForDatabaseMigration(testTableWithoutIndex) + val statements = MigrationUtils.statementsRequiredForDatabaseMigration(testTableWithoutIndex) assertEquals(1, statements.size) } finally { SchemaUtils.drop(testTableWithIndex)