Coexistence of Flyway in the embedded database (h2) of the development environment and the release database (SQL Server) with Spring Boot

Premise

--Create a server application that uses a database with Spring Boot --I'm using hibernate and I'm also initializing the database.

problem

--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

Solution

--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

Coexistence of Flyway in the embedded database (h2) of the development environment and the release database (SQL Server) with Spring Boot
Database environment construction with Docker in Spring boot (IntellJ)
Spring Boot2 Web application development with Visual Studio Code SQL Server connection
Until you can use the H2 database in server mode with Dropwizard using Eclipse and connect with DB Viewer.
Organize the differences in behavior of @NotBlank, @NotEmpty, @NotNull with Spring Boot + Thymeleaf
How to set environment variables in the properties file of Spring boot application
Create a Spring Boot development environment with docker
[Rough explanation] How to separate the operation of the production environment and the development environment with Rails
Check the behavior of getOne, findById, and query methods in Spring Boot + Spring Data JPA
[wip] Server-side development comfortably and freely with the server
Switch environment with Spring Boot application.properties and @Profile annotation
[For beginners] DI ~ The basics of DI and DI in Spring ~
Access the built-in h2db of spring boot with jdbcTemplate
SSO with GitHub OAuth in Spring Boot 1.5.x environment
Until you start development with Spring Boot in eclipse 1
How to boot by environment with Spring Boot of Maven
Until you start development with Spring Boot in eclipse 2
Branch processing by the return value of RestTemplate and the status code of ResponseEntity in Spring Boot
Change the injection target for each environment with Spring Boot 2
A story packed with the basics of Spring Boot (solved)
Extract SQL to property file with jdbcTemplate of spring boot
Connect to database with spring boot + spring jpa and CRUD operation
Domain Driven Development with Java and Spring Boot ~ Layers and Modules ~
Login with HttpServletRequest # login in Spring Security of Servlet 3.x environment
Easily develop web applications with STS and Spring Boot. In 10 minutes.
Get a proxy instance of the component itself in Spring Boot
I tried to build the environment of PlantUML Server with Docker
See the relative redirect behavior with the server.tomcat.use-relative-redirects setting in Spring Boot
Compare Hello, world! In Spring Boot with Java, Kotlin and Groovy
Spring validation was important in the order of Form and BindingResult
See the behavior of entity update with Spring Boot + Spring Data JPA
Install Rails in the development environment and create a new application
We will build a Spring Framework development environment in the on-premises environment.
Spring Boot application development in Eclipse
Hot deploy with Spring Boot development
Database linkage with doma2 (Spring boot)
Spring with Kotorin --9 Database migration --Flyway
I tried Flyway with Spring Boot
Determine the device type of smartphones, tablets, and PCs with Spring Mobile
Use Priority Queue with Kotlin (1.0.0) of AtCoder (+ Investigate the environment of the judge server)
Create a Spring Boot app development project with the cURL + tar command
Spring5 MVC web application development with Visual Studio Code SQL Server connection
Procedure to make the value of the property file visible in Spring Boot
Visualize your efforts! Development of stacking management app ~ Spring app release in 5 weeks ~
How to execute with commands of normal development language in Docker development environment
I examined the flow of TCP communication with Spring Integration (server edition)
Calculate the percentage of "good", "normal", and "bad" in the questionnaire using SQL
Introduction to Java development environment & Spring Boot application created with VS Code