Issue
I am getting the below error Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [my.table]
Is this any version issue? Most examples don't use schema even the official? https://github.com/spring-projects/spring-boot/tree/main/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-flyway
Database: MariaDB
Steps: Created V1__init.sql using
#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create #spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=V1__init.sql #spring.jpa.properties.javax.persistence.schema-generation.scripts.create-source=metadata
Then added flyway plugin
flyway.properties at same level as build.gradle
flyway.user=py1***
flyway.password=ENC(aCUoPgiA+ZyHDFdrEXa)
flyway.schemas=my
flyway.createSchemas=false
flyway.url=jdbc:mariadb://localhost:3306/my
flyway.locations=filesystem:db/migration
application.props
spring.jpa.properties.hibernate.default_schema=my
spring.jpa.hibernate.ddl-auto=validate
moved V1__init.sql to db\migrations
My entities don't specify schema
@Entity
@Table(uniqueConstraints={
@UniqueConstraint(....})
})
public class SomeTable {...}
Solution
Added dependency - implementation 'org.flywaydb:flyway-core' and it was resolved
(next error about json type column - found [longtext (Types#LONGVARCHAR)], but expecting [json (Types#VARCHAR)] which isn't in the scope of this post)
Answered By - Kris Swat