jjbuchan / docs

0 stars 0 forks source link

Creating a migration file for a new JPA Entity #17

Open jjbuchan opened 3 years ago

jjbuchan commented 3 years ago

By adding this configuration into a service's application.yml and running the service, it'll auto-generate a create.sql file in the project. You can then copy the relevant line out of that file and use it in a new migrations file.

spring:
  jpa:
    properties:
      javax:
        persistence:
          schema-generation:
            scripts:
              create-source: metadata
              action: create
              create-target: create.sql

Example sql generated:

image

There might be other better ways to do this(?) but this worked for me.