Database migration library

I would like to introduce Kotlin at work. We are primarily a Python/Django shop, but we’re starting a greenfield project and I have full latitude to choose the tech stack. Kotlin looks like a good fit for the most part, but my one qualm is with database migrations.

Django has a very easy to use migration generator. You edit your source files to add a new field to a model, you run ./ makemigrations, then ./ migrate, and you’re done. It handles dependencies, versioning, and everything else.

Is there anything similar in the Java/Kotlin ecosystem? Or at least, something that is actively-maintained, ergonomic to use, and isn’t just a gimped version of a commercial package?

You could use FlyWay - that is what we use in the company that I work for for database versioning.

However, as far as I know, FlyWay runs SQL scripts, which it cannot generate based on model classes - you would have to write those yourself.

It seems that JPA allows for generating DDL scripts from Entities: How to generate DDL from Entities

1 Like