Skip to content

Commit ae41c15

Browse files
staktracesvc-squareup-copybara
authored andcommitted
Move away from flyway for schema migration
Updates some documentation so that the misk schema migrator plugin is preferred GitOrigin-RevId: d0cb6cf1d6a5348413371ffd0fba675d6131f1da
1 parent 490d595 commit ae41c15

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

misk-jooq/README.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ a. Add the below lines to your build.gradle.kts
2121

2222
```
2323
plugins {
24-
alias(libs.plugins.flyway)
24+
alias(libs.plugins.miskSchemaMigrator)
2525
alias(libs.plugins.jooq)
2626
}
2727
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.
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
3939
jooq {
@@ -75,7 +75,7 @@ jooq {
7575
7676
// Needed to generate jooq test db classes
7777
tasks.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
9999
name and docker container name.
100100

101101
c. 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

misk-schema-migrator-gradle-plugin/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ miskSchemaMigrator {
3232
3333
// If you want to integrate with JOOQ
3434
// tasks.withType<nu.studer.gradle.jooq.JooqGenerate>().configureEach {
35-
// dependsOn("migrateSchemas")
35+
// dependsOn("migrateSchema")
3636
// }
37-
```
37+
```

0 commit comments

Comments
 (0)