--Create a server application that uses a database with Spring Boot --I'm using hibernate and I'm also initializing the database.
spring.jpa.hibernate.ddl-auto=update
--Local development environment starts embedded database using h2 on memory
--Initialize the database every time you start the app
--Of course, persistence is required at the release destination, so switch to another database
--This time SQL Server
--I need to change the schema of the database, so I want to manage the configuration with Flyway.--Apply Flyway and put SQL files in db / migration, but conflict between two types of databases. --H2 is used for local development, so no migration is required. ――It's okay to remake it every time --If you use SQL Server, please migrate
--Place SQL files separately for each vendor --Place a dummy SQL file for h2 --Hibernate initialization is not affected because Flyway's SQL is executed first (because the table has already been created)
application.properties
spring.flyway.locations=classpath:db/migration/{vendor}
src/main/resources/
db/
migration/
H2/
V1_0_0__dummy.sql
SQLSERVER/
V1_0_0__Initial.sql
V1_1_0__AddHoge.sql
V1_0_0__dummy.sql
select 'dummy';
Recommended Posts