Spring:Flyway: Unterschied zwischen den Versionen

Aus Alexander's Wiki
Zeile 49: Zeile 49:
mvn flyway:info
mvn flyway:info
mvn flyway:migrate
mvn flyway:migrate
mvn flyway:repair
</syntaxhighlight>
</syntaxhighlight>

Version vom 13. Mai 2022, 05:07 Uhr

Flyway in SpringBoot-Projekt

In pom.xml

<dependency>
    <groupId>org.flywaydb</groupId>
    <artifactId>flyway-core</artifactId>
    <version>${flyway.version}</version>
</dependency>
<dependency>
    <groupId>org.flywaydb</groupId>
    <artifactId>flyway-mysql</artifactId>
    <version>${flyway.version}</version>
</dependency>

In application.yaml

spring:
  flyway:
    enabled: true
    baselineOnMigrate: true
    check-location: true
    # schemas: public
    # unfortunately flyway cannot distinct between mysql and mariadb by {vendor}
    locations: classpath:db/migration/{vendor},classpath:db/migration/all #, filesystem:/opt/migration/{vendor}
    user: user
    password: password

Flyway in maven-Skript

flyway.conf in

  • installDir/conf/flyway.conf
  • userhome/flyway.conf
  • workingDir/flyway.conf
# Settings are simple key-value pairs
flyway.key=value
# Single line comment start with a hash

# Long properties can be split over multiple lines by ending each line with a backslash
flyway.locations=filesystem:my/really/long/path/folder1,\
filesystem:my/really/long/path/folder2,\
filesystem:my/really/long/path/folder3

# These are some example settings
flyway.url=jdbc:mydb://mydatabaseurl
flyway.schemas=schema1,schema2
flyway.placeholders.keyABC=valueXYZ

Befehle:

mvn flyway:info
mvn flyway:migrate
mvn flyway:repair