-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.kt
36 lines (34 loc) · 1.16 KB
/
Main.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import momosetkn.liquibase.client.LiquibaseDatabaseFactory
import momosetkn.liquibase.client.configureLiquibase
import java.sql.DriverManager
import kotlin.system.exitProcess
fun main() {
val connectionUrl = "jdbc:mysql://localhost:3316"
val username = "root"
val password = ""
val databaseName = "liquibase-kotlin-script-example" + System.currentTimeMillis()
Class.forName("com.mysql.cj.jdbc.Driver")
DriverManager.getConnection(connectionUrl, username, password).use { connection ->
connection.createStatement().use { statement ->
statement.executeUpdate("CREATE DATABASE IF NOT EXISTS `$databaseName`")
}
}
configureLiquibase {
global {
general {
showBanner = false
}
}
}
val database = LiquibaseDatabaseFactory.create(
driver = "com.mysql.cj.jdbc.Driver",
url = "$connectionUrl/$databaseName",
username = username,
password = password,
)
val client = momosetkn.liquibase.client.LiquibaseClient(
changeLogFile = "scriptchangelogs/db.changelog-all.kts",
database = database,
)
client.update()
}