Reputation: 4384
Is it somehow possible to have custom sql for creating a schema coexist with ddl auto generate? I can create a schema.sql
and it runs fine, but it takes precedence over the ddl auto generation and prevents any entities being auto generated. I would like to have my views be created with schema.sql
but my tables auto generated. I can create the views in data.sql
and that is a workaround, but semantically it doesn't make sense to have the views created there.
Upvotes: 2
Views: 235
Reputation: 6302
According to the documentation, you can't use the auto generation and schema.sql at the same time:
In a JPA-based app, you can choose to let Hibernate create the schema or use schema.sql, but you cannot do both. Make sure to disable spring.jpa.hibernate.ddl-auto if you use schema.sql.
So, you can keep the auto generation, data.sql and then configure Flyway to create the views.
For Flyway configration, load org.flywaydb:flyway-core in the classpath:
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>5.2.4</version>
</dependency>
Then create your first migration script on /resources/db/migration/V1__createviews.sql with the CREATE VIEW... statements.
Upvotes: 1