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.
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
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

