Skip to content

Commit

Permalink
PO-46: Rename database to opal-fines-db (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
sabahirfan authored Nov 13, 2023
1 parent 12333a9 commit 307282a
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The simplest way to run the application is using the `bootTestRun` Gradle task:
```

This task has no dependencies and starts up a Postgres database in Docker using [Testcontainers](https://testcontainers.com).
The database is available on `jdbc:postgresql://localhost:5432/opal_db` with username and password `opal`.
The database is available on `jdbc:postgresql://localhost:5432/opal-fines-db` with username and password `opal-fines`.

To persist the database between application restarts set the environment variable `TESTCONTAINERS_REUSE_ENABLE` to `true`.
Note this does **not** persist data if the Docker container is manually stopped, or through laptop restarts).
Expand Down
2 changes: 1 addition & 1 deletion charts/opal-account-enquiry/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ appVersion: "1.0"
description: A Helm chart for opal-account-enquiry app
name: opal-account-enquiry
home: https://github.com/hmcts/opal-account-enquiry
version: 0.0.15
version: 0.0.16
maintainers:
- name: HMCTS Opal Team
dependencies:
Expand Down
12 changes: 6 additions & 6 deletions charts/opal-account-enquiry/values.dev.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ java:
- name: app-insights-connection-string
alias: app-insights-connection-string
environment:
OPAL_DB_HOST: "{{ .Release.Name }}-postgresql"
OPAL_DB_NAME: "{{ .Values.postgresql.auth.database}}"
OPAL_DB_USERNAME: "{{ .Values.postgresql.auth.username}}"
OPAL_DB_PASSWORD: "{{ .Values.postgresql.auth.password}}"
OPAL_DB_OPTIONS: "?stringtype=unspecified"
OPAL_DB_PORT: 5432
OPAL_FINES_DB_HOST: "{{ .Release.Name }}-postgresql"
OPAL_FINES_DB_NAME: "{{ .Values.postgresql.auth.database}}"
OPAL_FINES_DB_USERNAME: "{{ .Values.postgresql.auth.username}}"
OPAL_FINES_DB_PASSWORD: "{{ .Values.postgresql.auth.password}}"
OPAL_FINES_DB_OPTIONS: "?stringtype=unspecified"
OPAL_FINES_DB_PORT: 5432
RUN_DB_MIGRATION_ON_STARTUP: true
postgresql:
enabled: true
10 changes: 5 additions & 5 deletions charts/opal-account-enquiry/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ java:
- name: app-insights-connection-string
alias: app-insights-connection-string
- name: account-enquiry-POSTGRES-HOST
alias: OPAL_DB_HOST
alias: OPAL_FINES_DB_HOST
- name: account-enquiry-POSTGRES-PASS
alias: OPAL_DB_PASSWORD
alias: OPAL_FINES_DB_PASSWORD
- name: account-enquiry-POSTGRES-PORT
alias: OPAL_DB_PORT
alias: OPAL_FINES_DB_PORT
- name: account-enquiry-POSTGRES-USER
alias: OPAL_DB_USERNAME
alias: OPAL_FINES_DB_USERNAME
- name: account-enquiry-POSTGRES-DATABASE
alias: OPAL_DB_NAME
alias: OPAL_FINES_DB_NAME
environment:
RUN_DB_MIGRATION_ON_STARTUP: true
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ services:
- LOGBACK_REQUIRE_THREAD
- LOGBACK_REQUIRE_ALERT_LEVEL=false
- LOGBACK_REQUIRE_ERROR_CODE=false
- OPAL_DB_HOST=opal-db
- OPAL_FINES_DB_HOST=opal-fines-db
ports:
- $SERVER_PORT:$SERVER_PORT

opal-db:
opal-fines-db:
image: postgres:15
restart: always
environment:
- POSTGRES_DB=opal_db
- POSTGRES_USER=opal
- POSTGRES_PASSWORD=opal
- POSTGRES_DB=opal-fines-db
- POSTGRES_USER=opal-fines
- POSTGRES_PASSWORD=opal-fines
ports:
- 5432:5432
volumes:
Expand Down
16 changes: 8 additions & 8 deletions infrastructure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ provider "azurerm" {
}

locals {
db_name = "opal"
db_name = "opal-fines-db"
}

module "opal_db" {
module "opal-fines-db" {
providers = {
azurerm.postgres_network = azurerm.postgres_network
}

source = "[email protected]:hmcts/terraform-module-postgresql-flexible?ref=master"
env = var.env

Expand All @@ -32,12 +32,12 @@ module "opal_db" {
]

pgsql_version = "15"

# The ID of the principal to be granted admin access to the database server.
# On Jenkins it will be injected for you automatically as jenkins_AAD_objectId.
# Otherwise change the below:
admin_user_object_id = var.jenkins_AAD_objectId

common_tags = var.common_tags
}

Expand All @@ -48,19 +48,19 @@ data "azurerm_key_vault" "key_vault" {

resource "azurerm_key_vault_secret" "POSTGRES-USER" {
name = "${var.component}-POSTGRES-USER"
value = module.opal_db.username
value = module.opal-fines-db.username
key_vault_id = data.azurerm_key_vault.key_vault.id
}

resource "azurerm_key_vault_secret" "POSTGRES-PASS" {
name = "${var.component}-POSTGRES-PASS"
value = module.opal_db.password
value = module.opal-fines-db.password
key_vault_id = data.azurerm_key_vault.key_vault.id
}

resource "azurerm_key_vault_secret" "POSTGRES_HOST" {
name = "${var.component}-POSTGRES-HOST"
value = module.opal_db.fqdn
value = module.opal-fines-db.fqdn
key_vault_id = data.azurerm_key_vault.key_vault.id
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ spring:
name: Opal Account Enquiry
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://${OPAL_DB_HOST:localhost}:${OPAL_DB_PORT:5432}/${OPAL_DB_NAME:opal_db}${OPAL_DB_OPTIONS:}
username: ${OPAL_DB_USERNAME:opal}
password: ${OPAL_DB_PASSWORD:opal}
url: jdbc:postgresql://${OPAL_FINES_DB_HOST:localhost}:${OPAL_FINES_DB_PORT:5432}/${OPAL_FINES_DB_NAME:opal-fines-db}${OPAL_FINES_DB_OPTIONS:}
username: ${OPAL_FINES_DB_USERNAME:opal-fines}
password: ${OPAL_FINES_DB_PASSWORD:opal-fines}
properties:
charSet: UTF-8
hikari:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ PostgreSQLContainer<?> databaseContainer() {
.withCreateContainerCmdModifier(cmd ->
cmd.withHostConfig(new HostConfig().withPortBindings(DB_PORT_BINDING)))
.withExposedPorts(DB_EXPOSED_PORT)
.withDatabaseName("opal_db")
.withUsername("opal")
.withPassword("opal")
.withDatabaseName("opal-fines-db")
.withUsername("opal-fines")
.withPassword("opal-fines")
.withReuse(true);
}
}

0 comments on commit 307282a

Please sign in to comment.