Hi, I’m creating an application using Exposed ORM ...
# exposed
c
Hi, I’m creating an application using Exposed ORM on Kotlin + Spring Boot and I’m trying to manage the changes in the database entity using the migration file. Can you guys share which method you’re using? I used a lot of NestJS + TypeORM stacks before, and TypeORM has a function that tracks changes to entities and automatically creates migration files, so I used it conveniently, but I can’t find that function in Exposed.
I’m going to hand over all the entities I created to
SchemaUtils.statementsRequiredForDatabaseMigration
function and run them whenever there’s a change, and I’m going to run the statements I told you about in
Flyway
Copy code
fun main() {
    Database.connect(
        url = "jdbc:h2:mem:~",
        driver = "org.h2.Driver",
    )

    transaction {
        val statementsRequiredForDatabaseMigration =
            SchemaUtils.statementsRequiredForDatabaseMigration(
                UserEntity,
                PostEntity,
            )
        println(statementsRequiredForDatabaseMigration.joinToString(separator = ";\n"))
    }
}
like this…. and I’m going to make this function as a Gradle task
c
Hi @cain.kim
MigrationUtils.generateMigrationScript()
may also be of use to you. It is available in the new
exposed-migration
module, which is available as of version 0.52.0.
👀 2
👍 1
👍🏾 1
c
thank you for response, I’ll try it and comment again!
👍 1