Create documentation
This commit is contained in:
37
docs/migrations/migrations-gradle.md
Normal file
37
docs/migrations/migrations-gradle.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# Execute Migrations with Gradle
|
||||
|
||||
You can execute migration with a Gradle task like this:
|
||||
|
||||
```kotlin
|
||||
// build.gradle.kts
|
||||
import fr.postgresjson.connexion.Connection
|
||||
import fr.postgresjson.connexion.Requester
|
||||
import fr.postgresjson.migration.Migrations
|
||||
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath("com.github.flecomte:postgres-json:+")
|
||||
}
|
||||
}
|
||||
|
||||
val migration by tasks.registering {
|
||||
doLast {
|
||||
val connection = Connection(
|
||||
host = "localhost",
|
||||
port = 5432,
|
||||
database = "database",
|
||||
username = "username",
|
||||
password = "password"
|
||||
)
|
||||
Migrations(
|
||||
connection,
|
||||
file("$buildDir/resources/main/sql/migrations").toURI(),
|
||||
file("$buildDir/resources/main/sql/functions").toURI()
|
||||
).run()
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```shell
|
||||
$ gradle migration
|
||||
```
|
||||
Reference in New Issue
Block a user