'Is it possible to use data.sql without schema.sql

I want to initialise schema using spring.jpa.generate-ddl=true and then populate using data.sql.

I tried it but it doesn't seem to work without schema.sql. Any suggesstions?



Solution 1:[1]

Add below config to your application.properties or application.yml file:

spring.jpa.hibernate.ddl-auto=create
spring.datasource.initialization-mode=always

and use below config if you have data in the table:

spring.jpa.hibernate.ddl-auto=update
spring.datasource.initialization-mode=always

See this question and its answer.

Solution 2:[2]

spring.jpa.defer-datasource-initialization=true

will load your data.sql script after your table is generated.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 kartik karmaran