statementsRequiredForDatabaseMigration

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.

Note: Some databases, like SQLite, only support ALTER TABLE ADD COLUMN syntax in very restricted cases, which may cause unexpected behavior when adding some missing columns. For more information, refer to the relevant documentation. For SQLite, see ALTER TABLE restrictions.

Note: If this method is called on a PostgreSQL database, it will check for a mapping inconsistency between the specified tables and existing sequences that have a relational dependency on any of these tables (for example, any sequence automatically associated with a SERIAL column registered to IdTable). This means that an unbound sequence created manually via the CREATE SEQUENCE command will no longer be checked and will not generate a DROP statement. When called on other databases, such an inconsistency will be checked against all sequences from the database, potentially returning DROP statements for any sequence unlinked or unrelated to tables.

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.