feat!: Added database migration support

This commit is contained in:
bedroomghost 2025-04-15 20:59:43 +02:00
parent f0fcbb588d
commit 7cd3b063bc
5 changed files with 31 additions and 4 deletions

View File

@ -10,3 +10,8 @@ spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
# H2 console # H2 console
spring.h2.console.enabled=true spring.h2.console.enabled=true
spring.h2.console.path=/h2-console 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

View File

@ -26,6 +26,15 @@
<artifactId>application</artifactId> <artifactId>application</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>11.7.1</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -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)
);

View File

@ -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');

View File

@ -42,10 +42,6 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>