Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Flyway is not creating the table but inserting the data

Flyway is not creating the table but inserting the data.

I am trying to create a table and insert data through flyway in spring boot application.

These are in my resource/db/migration folder.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

V1__Create_Hello.sql

CREATE TABLE hello (
        id INT AUTO_INCREMENT PRIMARY KEY,
        app VARCHAR(255) NOT NULL,
        key VARCHAR(255) NOT NULL,
        value TEXT,
        UNIQUE KEY unique_property (app, key)
);

I have another table called property where data insertion is happening perfectly. This table I have created manually

V2_Insert_properties.sql

INSERT INTO property (app,key, value) VALUES ('app', ‘key1’, ‘va’l1);

this is my flyway_schema_history

enter image description here

What can be the issue ?

Here is my application yml.

spring:
  application:
    name: config-server
  profiles:
    active: jdbc
  datasource:
    driverClassName: com.mysql.cj.jdbc.Driver
    url: "${MYSQL_URL:jdbc:mysql://localhost:3306/myDB}”
    username: "${MYSQL_USERNAME:root}"
    password: "${MYSQL_PASSWORD:root}"
  flyway:
      enabled: true
      baseline-on-migrate: true
      locations: "classpath:db/migration"
  cloud:
    config:
      server:
        jdbc:
          sql: SELECT property_key, property_value FROM property WHERE application = ? and profile = ? and label = ?
          order : 1
        encrypt:
          enabled: true
  jpa:
    show-sql: true
server:
  port: 8088

management:
  endpoints:
    web:
      exposure:
        include: "*"

>Solution :

Flyway V1 is meaning init, so V1__Create_Hello.sql is create as init. so it shows as baseline. Change file name to V2 or others.

And it should be noted that 3.2 of 3.10 or 3.2 runs first because the version is recognized as an integer.

https://documentation.red-gate.com/fd/quickstart-how-flyway-works-184127223.html

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading