MigrationUtils

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

Functions

Link copied to clipboard
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.

Link copied to clipboard
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.

Link copied to clipboard
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.