5 Mart 2023 Pazar

SpringData Flyway application.properties

baseline-on-migrate Alanı
Eğer şu hatayı alıyorsak
Use baseline() or set baselineOnMigrate to true to initialize the schema history table
Şöyle yaparız
spring: 
 flyway: 
 baseline-on-migrate: true
baseline-version Alanı
Şöyle yaparız
spring: 
 flyway: 
 baseline-on-migrate: true 
 baseline-version: 0
Açıklaması şöyle
If not, the scripts named V1__xxxx.sql would not execute. as the baseline-version default is version 1.
callbacks Alanı
Örnek
Şöyle yaparız
spring:
  flyway:
    enabled: true
    schemas: public
    baseline-on-migrate: true
    baseline-version: 0
    clean-disabled: true
    validate-on-migrate: true
    locations: classpath:db.migration
    placeholderReplacement: false
    callbacks: com.xxx.CsvUpsertCallback
SpringData Flyway Callbacks yazısına bakınız

clean-disabled Alanı
Örnek
Şöyle yaparız
spring: 
 flyway: 
 clean-disabled: true
debug
Örnek
Şöyle yaparız
logging: 
 level: 
 root: INFO 
 org: 
 flywaydb: DEBUG
locations Alanı
Normalde classpath:db/migration dizinini taranır.  Çıktısı şöyle
ClassPathScanner : Unable to resolve location classpath:db/callback.
ClassPathScanner : Scanning for classpath resources at 'classpath:db/migration' …
...
Örnek
Şöyle yaparız. Burada flyway'in arayacağı scriptlerin dizini belirtiliyor.
flyway:
  datasources:
    default:
      enabled: true
      baseline-on-migrate: true
      locations: classpath:db/mymigration
group Alanı
Açıklaması şöyle
The property spring.flyway.group set to true indicates we want to run the pending migrations in a single transaction instead of one transaction per pending migrations. So if one migration fails, all the executed migrations before will be rollbacked.
Örnek
Şöyle yaparız
spring.flyway.enabled=true
spring.flyway.url=jdbc:mysql://localhost:3307/blog?serverTimezone=UTC&useSSL=false
spring.flyway.user=root
spring.flyway.password=secretpswd
spring.flyway.group=true
schemas Alanı
Örnek
Şöyle yaparız
# Flyway properties
spring.flyway.enabled=true
spring.flyway.url=YOUR_DB_URL
spring.flyway.password= YOUR_DB_PASSWORD
spring.flyway.user= YOUR_DB_USERNAME
spring.flyway.schemas=migrations
spring.flyway.locations=classpath:db/migration/postgresql
Örnek
Şöyle yaparız
spring: 
 flyway: 
 placeholders: 
 mySchema: yourSchema
Şöyle yaparız
CREATE TABLE ${mySchema}.template 
( 
 id bigint NOT NULL, 
 code character varying(255) NOT NULL, 
 PRIMARY KEY (id) 
);

Hiç yorum yok:

Yorum Gönder