Create an extended momosetkn.liquibase.kotlin.parser.KotlinCompiledDatabaseChangeLog class. and add any changeSet.
// src/main/kotlin/example/DatabaseChangelog20241007Employee1.kt
package example
import momosetkn.liquibase.kotlin.parser.KotlinCompiledDatabaseChangeLog
class DatabaseChangelog20241007Employee1 : KotlinCompiledDatabaseChangeLog({
changeSet(author = "your_name", id = "20241007-2000-1") {
createTable(tableName = "employee") {
column(name = "id", type = "UUID") {
constraints(nullable = false, primaryKey = true)
}
column(name = "company_id", type = "UUID") {
constraints(nullable = false)
}
column(name = "name", type = "VARCHAR(256)")
column(name = "not_null_name", type = "VARCHAR(256)") {
constraints(nullable = false)
}
column(name = "not_null_name2", type = "VARCHAR(256)") {
constraints(nullable = false)
}
}
}
})
specify class-name as changeLogFile to LiquibaseClient.
val client = momosetkn.liquibase.client.LiquibaseClient(
// set class-name
changeLogFile = example.DatabaseChangelog20241007Employee1::class.qualifiedName!!,
database = database,
)
client.update()
Put kts-file under the resource directory.
// src/main/resource/db/changelog/db.changelog-20241007-employee-1.kts
databaseChangeLog {
changeSet(author = "your_name", id = "20241007-2000-1") {
createTable(tableName = "employee") {
column(name = "id", type = "UUID") {
constraints(nullable = false, primaryKey = true)
}
column(name = "company_id", type = "UUID") {
constraints(nullable = false)
}
column(name = "name", type = "VARCHAR(256)")
column(name = "not_null_name", type = "VARCHAR(256)") {
constraints(nullable = false)
}
column(name = "not_null_name2", type = "VARCHAR(256)") {
constraints(nullable = false)
}
}
}
}
specify file-path as changeLogFile to LiquibaseClient.
val client = momosetkn.liquibase.client.LiquibaseClient(
// set a file-path in the resource directory.
changeLogFile = "db/changelog/db.changelog-20241007-employee-1.kts",
database = database,
)
client.update()