# MigrationUtils

object MigrationUtils : MigrationUtilityApi

Utility functions that assist with generating the necessary SQL statements to migrate database schema objects.

## Functions

dropUnmappedColumnsStatements
Link copied to clipboard
suspend fun dropUnmappedColumnsStatements(vararg tables: Table, withLogs: Boolean = true): List<String>

Returns the SQL statements that drop any columns that exist in the database but are not defined in tables.

dropUnmappedIndices
Link copied to clipboard
suspend fun dropUnmappedIndices(vararg tables: Table, withLogs: Boolean = true): List<String>

Returns the SQL statements that drop any indices that exist in the database but are not defined in tables.

dropUnmappedSequences
Link copied to clipboard
suspend fun dropUnmappedSequences(vararg tables: Table, withLogs: Boolean = true): List<String>

Returns the SQL statements that drop any sequences that exist in the database but are not defined in tables.

generateMigrationScript
Link copied to clipboard
suspend fun generateMigrationScript(vararg tables: Table, scriptDirectory: String, scriptName: String, withLogs: Boolean = true): File

This function simply generates the migration script without applying the migration. Its purpose is to show what the migration script will look like before applying the migration. If a migration script with the same name already exists, its content will be overwritten.

statementsRequiredForDatabaseMigration
Link copied to clipboard
suspend fun statementsRequiredForDatabaseMigration(vararg tables: Table, withLogs: Boolean = true): List<String>

Returns the SQL statements that need to be executed to make the existing database schema compatible with the table objects defined using Exposed. Unlike `SchemaUtils.statementsRequiredToActualizeScheme()`, DROP/DELETE statements are included.