-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ESWE-1181] Add DB (PostgreSQL) #22
Conversation
rickchoijd
commented
Jan 28, 2025
- Added local DB (PostgreSQL)
- Added Flyway
- Enabled JPA
- Added local DB (PostgreSQL) - Added Flyway - Enabled JPA
@@ -13,9 +13,13 @@ ext["logback.version"] = "1.5.15" | |||
dependencies { | |||
implementation("uk.gov.justice.service.hmpps:hmpps-kotlin-spring-boot-starter:1.1.1") | |||
implementation("uk.gov.justice.service.hmpps:hmpps-sqs-spring-boot-starter:5.2.2") | |||
implementation("org.springframework.boot:spring-boot-starter-data-jpa") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add JPA
runtimeOnly("org.flywaydb:flyway-database-postgresql") | ||
runtimeOnly("org.postgresql:postgresql") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using Flyway with PostgreSQL
@@ -45,6 +49,7 @@ testing { | |||
implementation("org.apache.commons:commons-compress:1.27.1") | |||
} | |||
implementation("org.testcontainers:localstack") | |||
implementation("org.testcontainers:postgresql") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
running PostgreSQL container for integration tests
rds-postgresql-instance-output: | ||
DATABASE_USERNAME: "database_username" | ||
DATABASE_PASSWORD: "database_password" | ||
DATABASE_NAME: "database_name" | ||
DATABASE_ENDPOINT: "rds_instance_endpoint" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pull in DB parameters from secrets (prepared before during DB bootstrap with TF)
@@ -54,10 +55,20 @@ abstract class IntegrationTestBase { | |||
|
|||
companion object { | |||
private val localStackContainer by lazy { LocalStackContainer.instance } | |||
private val postgresContainer = PostgresContainer.flywayContainer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provide a postgreSQL for integration tests with Flyway enabled
(another will be for JPA repository tests without Flyway)
val flywayContainer: PostgreSQLContainer<Nothing>? by lazy { startPostgresqlContainer() } | ||
val repositoryContainer: PostgreSQLContainer<Nothing>? by lazy { startPostgresqlContainer() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using two different postgreSQL containers for different integration tests (with or without Flyway)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for integration tests with Flyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for local run with DB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enable Flyway by default