migration add
This commit is contained in:
10
pom.xml
10
pom.xml
@@ -45,6 +45,10 @@
|
|||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.flywaydb</groupId>
|
||||||
|
<artifactId>flyway-core</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springdoc</groupId>
|
<groupId>org.springdoc</groupId>
|
||||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
@@ -100,6 +104,12 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.flywaydb</groupId>
|
||||||
|
<artifactId>flyway-maven-plugin</artifactId>
|
||||||
|
<version>10.17.0</version>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import ru.ip.example.service.FilmService;
|
|||||||
import ru.ip.example.service.SeazonService;
|
import ru.ip.example.service.SeazonService;
|
||||||
import ru.ip.example.service.SeriesService;
|
import ru.ip.example.service.SeriesService;
|
||||||
|
|
||||||
|
//ссылка на h2 БД http://localhost:8080/h2-console
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class ExampleApplication {
|
public class ExampleApplication {
|
||||||
|
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
package ru.ip.example.config;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import ru.ip.example.domain.entity.FilmEntity;
|
|
||||||
import ru.ip.example.domain.entity.SeazonEntity;
|
|
||||||
import ru.ip.example.domain.entity.SeriesEntity;
|
|
||||||
import ru.ip.example.domain.entity.SubscribeEntity;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class EntityInitializerConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public List<SubscribeEntity> subscribes() {
|
|
||||||
ArrayList<SubscribeEntity> subscribes = new ArrayList<>();
|
|
||||||
subscribes.add(SubscribeEntity.builder()
|
|
||||||
.id(0)
|
|
||||||
.name("Базовая")
|
|
||||||
.sum(200)
|
|
||||||
.build());
|
|
||||||
return subscribes;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public List<SeriesEntity> series() {
|
|
||||||
ArrayList<SeriesEntity> series = new ArrayList<>();
|
|
||||||
series.add(SeriesEntity.builder()
|
|
||||||
.id(0)
|
|
||||||
.name("Начало")
|
|
||||||
.number(1)
|
|
||||||
.build());
|
|
||||||
return series;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public List<SeazonEntity> seazons(List<SeriesEntity> series) {
|
|
||||||
ArrayList<SeazonEntity> seazons = new ArrayList<>();
|
|
||||||
seazons.add(SeazonEntity.builder()
|
|
||||||
.id(0)
|
|
||||||
.number(1)
|
|
||||||
.series(series)
|
|
||||||
.build());
|
|
||||||
return seazons;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public List<FilmEntity> films(List<SeazonEntity> seazons) {
|
|
||||||
ArrayList<FilmEntity> films = new ArrayList<>();
|
|
||||||
films.add(FilmEntity.builder()
|
|
||||||
.id(0)
|
|
||||||
.title("Блич")
|
|
||||||
.category("Фэнтези")
|
|
||||||
.releaseYear(2005)
|
|
||||||
.seazons(seazons)
|
|
||||||
.build());
|
|
||||||
return films;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,7 +18,7 @@ public class SubscribeEntity {
|
|||||||
@EqualsAndHashCode.Include
|
@EqualsAndHashCode.Include
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
private Integer sum;
|
private Integer amount;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package ru.ip.example.repository;
|
|||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
import ru.ip.example.domain.entity.FilmEntity;
|
import ru.ip.example.domain.entity.FilmEntity;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface FilmRepository extends CrudRepository<FilmEntity, Integer> {
|
public interface FilmRepository extends CrudRepository<FilmEntity, Integer> {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
package ru.ip.example.repository;
|
package ru.ip.example.repository;
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
import ru.ip.example.domain.SeazonDto;
|
|
||||||
import ru.ip.example.domain.entity.FilmEntity;
|
|
||||||
import ru.ip.example.domain.entity.SeazonEntity;
|
import ru.ip.example.domain.entity.SeazonEntity;
|
||||||
import ru.ip.example.domain.entity.SeriesEntity;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface SeazonRepository extends CrudRepository<SeazonEntity, Integer> {
|
public interface SeazonRepository extends CrudRepository<SeazonEntity, Integer> {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,3 +5,10 @@ spring.datasource.username=sa
|
|||||||
spring.datasource.password=password
|
spring.datasource.password=password
|
||||||
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
|
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
|
||||||
spring.h2.console.enabled=true
|
spring.h2.console.enabled=true
|
||||||
|
|
||||||
|
flyway.user=sa
|
||||||
|
flyway.password=password
|
||||||
|
flyway.url=jdbc:h2:mem:testdb
|
||||||
|
flyway.locations=classpath:db/migration
|
||||||
|
spring.flyway.enabled=true
|
||||||
|
|
||||||
|
|||||||
4
src/main/resources/db/migration/V0__data_insert.sql
Normal file
4
src/main/resources/db/migration/V0__data_insert.sql
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
INSERT INTO film(id, title, category, release_year) VALUES(0, 'Блич', 'Фэнтези', 2001);
|
||||||
|
INSERT INTO seazon(id, number, film_id) VALUES(0, 1, 0);
|
||||||
|
INSERT INTO series(id, name, number, seazon_id) VALUES(0, 'Начало', 1, 0);
|
||||||
|
INSERT INTO subscribe(id, name, amount) VALUES(0, 'Базовая', 200);
|
||||||
Reference in New Issue
Block a user