2

I'm looking to generate an SQL script that creates the tables I need in the database based on the my configuration setup in Spring Boot.

I've got this application-prod.yml config

spring:
  datasource:
    url: jdbc:oracle:thin:@removed:1521:XE
    username: user
    password: pass
  jpa:
    hibernate:
      ddl-auto: none
      naming:
        physical-strategy: CustomPhysicalNamingStrategyImpl
    properties:
      hibernate:
        default_schema: myschema

I used to just do ddl-auto: create-drop, but that is no longer an option.

In ASP.NET Core I'm used to doing it via the command line. Like so:

> dotnet ef --output create.sql

And I'm done.

But I can't find an equivalent way for Spring Boot and Hibernate.

Right now it seems like I have to edit my config run the app, export the database schema via Oracle SQL Developer, then revert the config. Hope I don't forget something.

Surely this can't be the case...

Snæbjørn
  • 10,322
  • 14
  • 65
  • 124
  • `that is no longer an option` You might want to explain why (such as a change from Spring Boot 1.5 to 2.0, or something else). – chrylis -cautiouslyoptimistic- Sep 07 '18 at 09:13
  • The db user dones't have create permissions – Snæbjørn Sep 07 '18 at 09:16
  • 1
    Try to use liquibase: https://medium.com/@harittweets/evolving-your-database-using-spring-boot-and-liquibase-844fcd7931da – Bartek Sep 07 '18 at 09:17
  • Possible duplicate of [How to generate a ddl creation script with a modern Spring Boot + Data JPA and Hibernate setup?](https://stackoverflow.com/questions/36966337/how-to-generate-a-ddl-creation-script-with-a-modern-spring-boot-data-jpa-and-h) – Simon Martinelli Sep 07 '18 at 13:59

0 Answers0