@@ -21,19 +21,19 @@ a. Add the below lines to your build.gradle.kts
21
21
22
22
```
23
23
plugins {
24
- alias(libs.plugins.flyway )
24
+ alias(libs.plugins.miskSchemaMigrator )
25
25
alias(libs.plugins.jooq)
26
26
}
27
27
val 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.
29
29
// 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"
33
33
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))
37
37
}
38
38
// More details about the jooq plugin here - https://github.com/etiennestuder/gradle-jooq-plugin
39
39
jooq {
75
75
76
76
// Needed to generate jooq test db classes
77
77
tasks.withType<nu.studer.gradle.jooq.JooqGenerate>().configureEach {
78
- dependsOn("flywayMigrate ")
78
+ dependsOn("migrateSchema ")
79
79
80
80
// declare migration files as inputs on the jOOQ task and allow it to
81
81
// participate in build caching
@@ -95,7 +95,7 @@ sourceSets {
95
95
}
96
96
```
97
97
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
99
99
name and docker container name.
100
100
101
101
c. Run ` jooq-test-regenerate.sh ` to have your model generated for you and ready to use.
@@ -162,10 +162,7 @@ ctx.select()
162
162
163
163
## Future
164
164
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 ` .
169
166
The issue is jooq.jar ships with a directory called ` migrations ` with the some
170
167
[ migrations] ( https://github.com/jOOQ/jOOQ/tree/main/jOOQ/src/main/resources/migrations )
171
168
we don't care about in it. When the service starts up it finds this folder as well and tries
0 commit comments