@@ -21,19 +21,19 @@ a. Add the below lines to your build.gradle.kts
2121
2222```
2323plugins {
24- alias(libs.plugins.flyway )
24+ alias(libs.plugins.miskSchemaMigrator )
2525 alias(libs.plugins.jooq)
2626}
2727val dbMigrations = "src/main/resources/db-migrations"
28- // We are using flyway here in order to run the migrations to create a schema.
28+ // We are using the schema migrator plugin here in order to run the migrations to create a schema.
2929// Ensure the migration directory is not called `migrations`. There's more details as to why below.
30- flyway {
31- url = "jdbc:mysql://localhost:3500/ misk-jooq-test-codegen"
32- user = "root"
30+ miskSchemaMigrator {
31+ database = "misk-jooq-test-codegen" // change this to your service name
32+ username = "root"
3333 password = "root"
34- schemas = arrayOf("jooq")
35- locations = arrayOf("filesystem:${project.projectDir}/${dbMigrations}")
36- sqlMigrationPrefix = "v"
34+ host = "localhost"
35+ port = 3500
36+ migrationsDir.set(layout.projectDirectory.dir(dbMigrations))
3737}
3838// More details about the jooq plugin here - https://github.com/etiennestuder/gradle-jooq-plugin
3939jooq {
7575
7676// Needed to generate jooq test db classes
7777tasks.withType<nu.studer.gradle.jooq.JooqGenerate>().configureEach {
78- dependsOn("flywayMigrate ")
78+ dependsOn("migrateSchema ")
7979
8080 // declare migration files as inputs on the jOOQ task and allow it to
8181 // participate in build caching
@@ -95,7 +95,7 @@ sourceSets {
9595}
9696```
9797
98- b. Have a look at ` jooq-test-regenerate.sh ` . Copy that into the root of your project and modify the database
98+ b. Have a look at ` jooq-test-regenerate.sh ` . Copy that into the root of your project and modify the database
9999name and docker container name.
100100
101101c. Run ` jooq-test-regenerate.sh ` to have your model generated for you and ready to use.
@@ -162,10 +162,7 @@ ctx.select()
162162
163163## Future
164164
165- 1 . The generation tool uses flyway to generate the schema. I would like to use misk-jdbc's
166- SchemaMigrationService built into a gradle plugin. That same plugin can also generate the
167- jooq classes.
168- Further, in order to use jooq we can't have migrations placed in a folder called ` migrations ` .
165+ 1 . Further, in order to use jooq we can't have migrations placed in a folder called ` migrations ` .
169166 The issue is jooq.jar ships with a directory called ` migrations ` with the some
170167 [ migrations] ( https://github.com/jOOQ/jOOQ/tree/main/jOOQ/src/main/resources/migrations )
171168 we don't care about in it. When the service starts up it finds this folder as well and tries
0 commit comments