* Added the dependency for the PostgreSQL-driver
* Added the new profile
* Configured Flyway to apply db-specific SQL
* Added a PostgreSQL-DB to the setup for Docker Compose as "postgres"
* Added a named volume for the data of the service "postgres"
* Selected the new profile "prod" for the service "jdbc"
image: jdbc:latest
ports:
- 8080:8080
+ environment:
+ spring.profiles.active: prod
+
+ postgres:
+ image: postgres:13
+ ports:
+ - 5432:5432
+ environment:
+ POSTGRES_USER: outbox
+ POSTGRES_PASSWORD: outbox
+ POSTGRES_DB: outbox
+ volumes:
+ - pgdata:/var/lib/postgresql/data/
+
+volumes:
+ pgdata:
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
web:
exposure:
include: "*"
+
+spring:
+ flyway:
+ locations: classpath:db/migration/h2
+
+---
+
+spring:
+ profiles: prod
+ datasource:
+ url: jdbc:postgresql://postgres:5432/outbox
+ username: outbox
+ password: outbox
+ flyway:
+ locations: classpath:db/migration/postgres
+++ /dev/null
-CREATE TABLE users (id BIGINT PRIMARY KEY AUTO_INCREMENT, username VARCHAR(255), created TIMESTAMP, logged_in BIT);
--- /dev/null
+CREATE TABLE users (id BIGINT PRIMARY KEY AUTO_INCREMENT, username VARCHAR(255), created TIMESTAMP, logged_in BIT);
--- /dev/null
+CREATE SEQUENCE users_id_seq;
+CREATE TABLE users (id BIGINT PRIMARY KEY NOT NULL DEFAULT NEXTVAL('users_id_seq'), username VARCHAR(255), created TIMESTAMP, logged_in BOOLEAN);
+ALTER SEQUENCE users_id_seq OWNED BY users.id;