Skip to content
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

Merged
merged 1 commit into from
Jan 29, 2025
Merged

[ESWE-1181] Add DB (PostgreSQL) #22

merged 1 commit into from
Jan 29, 2025

Conversation

rickchoijd
Copy link
Contributor

  • 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")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add JPA

Comment on lines +20 to +21
runtimeOnly("org.flywaydb:flyway-database-postgresql")
runtimeOnly("org.postgresql:postgresql")
Copy link
Contributor Author

@rickchoijd rickchoijd Jan 28, 2025

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")
Copy link
Contributor Author

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

Comment on lines +39 to +43
rds-postgresql-instance-output:
DATABASE_USERNAME: "database_username"
DATABASE_PASSWORD: "database_password"
DATABASE_NAME: "database_name"
DATABASE_ENDPOINT: "rds_instance_endpoint"
Copy link
Contributor Author

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
Copy link
Contributor Author

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)

Comment on lines +10 to +11
val flywayContainer: PostgreSQLContainer<Nothing>? by lazy { startPostgresqlContainer() }
val repositoryContainer: PostgreSQLContainer<Nothing>? by lazy { startPostgresqlContainer() }
Copy link
Contributor Author

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)

Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enable Flyway by default

@rickchoijd rickchoijd merged commit a84c921 into main Jan 29, 2025
6 checks passed
@rickchoijd rickchoijd deleted the ESWE-1181-init-db-1 branch January 29, 2025 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants