SchemaMigrator

class SchemaMigrator(driver: KilnDriver)

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.

The connection is borrowed, so reconciliation leaves it as it found it: a rebuild never deletes rows in tables that reference this one, and foreign-key enforcement ends up however it started.

Constructors

Link copied to clipboard
constructor(driver: KilnDriver)

Functions

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