SchemaMigrator

class SchemaMigrator(driver: SqlDriver)

Automatic schema migration — called inside every generated createTable().

Decision logic:

  • No change → no-op

  • Only new columns → fast path: ALTER TABLE ADD COLUMN for each

  • Orphaned columns → slow path: full 12-step table recreation (drops dead columns)

  • Renamed column → add @Column(migrateFrom="old_name"); triggers slow path, data copied from old column into new one

  • Type changed → slow path; old data CAST into the new declared type

Removed columns are always cleaned up — they never linger as orphans.

Constructors

Link copied to clipboard
constructor(driver: SqlDriver)

Functions

Link copied to clipboard
fun sync(tableName: String, expectedColumns: List<ColumnDef>)