diff --git a/boot/src/main/resources/application.properties b/boot/src/main/resources/application.properties index c02d384..1da086d 100644 --- a/boot/src/main/resources/application.properties +++ b/boot/src/main/resources/application.properties @@ -10,3 +10,8 @@ spring.jpa.database-platform=org.hibernate.dialect.H2Dialect # H2 console spring.h2.console.enabled=true spring.h2.console.path=/h2-console + +# Flyway +spring.flyway.enabled=true +spring.flyway.locations=filesystem:infrastructure/out/sql-repository/sql/migration +spring.flyway.baseline-on-migrate=true \ No newline at end of file diff --git a/infrastructure/out/sql-repository/pom.xml b/infrastructure/out/sql-repository/pom.xml index a15cfe6..334c736 100644 --- a/infrastructure/out/sql-repository/pom.xml +++ b/infrastructure/out/sql-repository/pom.xml @@ -26,6 +26,15 @@ application 0.0.1-SNAPSHOT + + org.flywaydb + flyway-maven-plugin + 11.7.1 + + + com.h2database + h2 + \ No newline at end of file diff --git a/infrastructure/out/sql-repository/sql/migration/V1__create_prices_table.sql b/infrastructure/out/sql-repository/sql/migration/V1__create_prices_table.sql new file mode 100644 index 0000000..301a730 --- /dev/null +++ b/infrastructure/out/sql-repository/sql/migration/V1__create_prices_table.sql @@ -0,0 +1,11 @@ +CREATE TABLE prices ( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + brand_id BIGINT NOT NULL, + start_date TIMESTAMP NOT NULL, + end_date TIMESTAMP NOT NULL, + price_list BIGINT NOT NULL, + product_id BIGINT NOT NULL, + priority BIGINT NOT NULL, + price DECIMAL(10, 2) NOT NULL, + currency VARCHAR(3) +); \ No newline at end of file diff --git a/infrastructure/out/sql-repository/sql/migration/V2__insert_prices_data.sql b/infrastructure/out/sql-repository/sql/migration/V2__insert_prices_data.sql new file mode 100644 index 0000000..5ad9204 --- /dev/null +++ b/infrastructure/out/sql-repository/sql/migration/V2__insert_prices_data.sql @@ -0,0 +1,6 @@ +INSERT INTO prices (brand_id, start_date, end_date, price_list, product_id, priority, price, currency) +VALUES + (1, '2020-06-14 00:00:00', '2020-12-31 23:59:59', 1, 35455, 0, 35.50, 'EUR'), + (1, '2020-06-14 15:00:00', '2020-06-14 18:30:00', 2, 35455, 1, 25.45, 'EUR'), + (1, '2020-06-15 00:00:00', '2020-06-15 11:00:00', 3, 35455, 1, 30.50, 'EUR'), + (1, '2020-06-15 16:00:00', '2020-12-31 23:59:59', 4, 35455, 1, 38.95, 'EUR'); \ No newline at end of file diff --git a/pom.xml b/pom.xml index a8adf7a..60e4ead 100644 --- a/pom.xml +++ b/pom.xml @@ -42,10 +42,6 @@ org.springframework.boot spring-boot-starter-data-jpa - - com.h2database - h2 - org.projectlombok lombok