I have a problem. I want the person table to be created when micronaut starts up. To do this, I use flyway, connected the dependency like this:
//----Micronaut Data
implementation("io.micronaut.data:micronaut-data-jdbc")
implementation("io.micronaut.sql:micronaut-jdbc-hikari")
implementation("io.micronaut.sql:micronaut-jooq")
//---FlyWay and Postgresql
runtimeOnly("org.postgresql:postgresql")
implementation("io.micronaut.flyway:micronaut-flyway")
runtimeOnly("org.flywaydb:flyway-core")
Further, in application.yml I wrote the configuration for Flyway. I will send the entire application yml file:
micronaut:
application:
name: demo7
server:
port: 9000
datasources:
default:
driver-class-name: org.postgresql.Driver
db-type: postgres
dialect: POSTGRES
username: postgres
url: jdbc:postgresql://localhost:5432/disa
password: 1234
netty:
default:
allocator:
max-order: 3
flyway:
datasources:
enabled: true
url: jdbc:postgresql://localhost:5432/disa
username: postgres
password: 1234
When the application starts, no errors are thrown, but the table is not created either. My db.migration path looks like this:
Name of my SQL script: V1_1__create_all_tables.sql Help me please. My sql script:
CREATE TABLE person(
id bigint primary key not null,
name varchar(255) not null,
age int not null
)
Make sure you add the datasource name default
to your Flyway configuration.
flyway:
datasources:
default:
enabled: true
And you don't need to copy the credentials and the connection string.