DB Migration Tool for Kotlin. Inspired by harmonica.
- New Syntax
- Type Support
- Alter
- Sequence
- Create user guide
- Down
- Target
- SEEDING
- Gradle Plugin - generate
- Gradle Plugin - migrate
- Gradle Plugin - rollback
- Gradle Plugin - check
Add otter dependencies and task within your application.
// build.gradle.kts/** ... */
dependencies {
/** ... */
implementation("io.github.goodgoodjm:otter-spring-boot-starter:0.0.23")
implementation(kotlin("script-runtime")) // for migration files of resources/** ... */
}
// This task is needed to boot jar file
tasks.getByName<org.springframework.boot.gradle.tasks.bundling.BootJar>("bootJar") {
requiresUnpack("**/kotlin-compiler-embeddable-*.jar")
}
/** ... */Add otter variables to your application's properties.
# application.ymlotter:
driverClassName: ${spring.datasource.driver-class-name}url: ${spring.datasource.url}username: ${spring.datasource.username}password: ${spring.datasource.password}migrationPath: migrationsshowSql: trueMake your migration files at migrationPath.
// resources/migrations/M2022071016263342.ktsimportio.github.goodgoodjm.otter.core.Migrationimportio.github.goodgoodjm.otter.core.dsl.Constraintimportio.github.goodgoodjm.otter.core.dsl.andobject:Migration() {
overridefunup() {
createTable("person") {
"id"-INT constraints PRIMARYandAUTO_INCREMENT"name"-VARCHAR(30)
"message"-VARCHAR"lat"-LONG constraints UNIQUE"nullable"-BOOL constraints NULLABLE
}
createTable("post") {
"id"-INT constraints PRIMARYandAUTO_INCREMENT"person_id"-INT foreignKey "person(id)"
}
}
overridefundown() {
dropTable("person")
dropTable("post")
}
}