Skip to content

Conversation

@devin-ai-integration
Copy link

Migrate Spring Boot Banking Application from MySQL 8 to PostgreSQL 15

Summary

Complete database migration from MySQL 8.0 to PostgreSQL 15 across all deployment configurations (Docker Compose, Kubernetes, and Helm charts). This migration updates:

  • Maven dependencies: Replaced mysql-connector-java with PostgreSQL driver
  • Application properties: Updated JDBC driver, URL, and Hibernate dialect to PostgreSQL
  • Docker Compose: Changed to postgres:15 image, updated env vars (POSTGRES_*), health checks (pg_isready), and volume paths
  • Kubernetes manifests: Updated 7 files including deployment, service, ConfigMap, Secrets, and persistent volumes
  • Helm charts: Updated 7 templates with PostgreSQL configuration including StatefulSet, Service, ConfigMap, Secrets, and init containers

Key changes:

  • Database image: mysql:8.0postgres:15
  • Service port: 33065432
  • Service name: mysql-svcpostgres-svc
  • Environment variables: MYSQL_*POSTGRES_*
  • Volume mount path: /var/lib/mysql/var/lib/postgresql/data
  • Health checks: mysqladmin pingpg_isready -U postgres
  • JDBC URLs: jdbc:mysql://...jdbc:postgresql://...

Preserved:

  • Database name: BankDB
  • Database password: Test@123 (Base64: VGVzdEAxMjM=)
  • JPA entities remain unchanged (database-agnostic annotations)

Review & Testing Checklist for Human

⚠️ CRITICAL - This PR was not tested end-to-end due to lack of testing instructions in repo setup. Human verification is essential.

  • Deploy and test using Docker Compose - Run docker-compose up and verify:

    • PostgreSQL container starts successfully with health check passing
    • Application connects to PostgreSQL on port 5432
    • Database schema is created correctly via Hibernate DDL
    • Application functionality works (create accounts, transactions)
  • Deploy and test on Kubernetes - Apply all manifests and verify:

    • postgres deployment starts successfully
    • postgres-svc service is accessible on port 5432
    • ConfigMap has correct JDBC URL: jdbc:postgresql://postgres-svc.bankapp-namespace.svc.cluster.local:5432/BankDB
    • Secret postgres-secret contains POSTGRES_PASSWORD key
    • Persistent volume mounts to /var/lib/postgresql/data
    • BankApp deployment connects successfully to PostgreSQL
  • Deploy and test using Helm - Run helm install and verify:

    • StatefulSet uses postgres:15 image
    • Init container waits for postgres on port 5432 before starting app
    • Health checks (pg_isready -U postgres) work for liveness and readiness probes
    • Headless service postgres-headless resolves correctly
    • ConfigMap JDBC URL references correct StatefulSet pod: postgres-0.postgres-headless...
    • Application can read/write data to PostgreSQL
  • Verify Maven dependency resolution - Run mvn dependency:tree and confirm:

    • PostgreSQL driver is resolved correctly
    • No MySQL dependencies remain
    • Application builds successfully
  • Verify data persistence - After successful deployment:

    • Create test data in the banking application
    • Restart/redeploy the PostgreSQL pod/container
    • Confirm data persists after restart

Test Plan

  1. Start with Docker Compose deployment (simplest to test)
  2. Create test accounts and transactions
  3. Restart containers and verify data persists
  4. Deploy to Kubernetes and repeat tests
  5. Deploy via Helm and repeat tests
  6. Verify health checks are working in all environments

Notes

  • All 17 configuration files have been updated systematically
  • Verified no remaining MySQL references using codebase search
  • JPA entities use standard annotations compatible with both databases
  • No custom SQL queries exist in the codebase (confirmed via repository search)
  • File names kept as-is (e.g., mysql-deployment.yml) to minimize changes - optional to rename later
  • Username changed from root to postgres (PostgreSQL default)

Requested by: Satwik Bebortha (@satwik-cog)
Devin run: https://app.devin.ai/sessions/7eed8ba1c24542939f702bd8fbb1f2be

- Replace MySQL connector with PostgreSQL driver in pom.xml
- Update Docker Compose: postgres:15 image, POSTGRES_* env vars, pg_isready health check
- Update application.properties: PostgreSQL dialect, JDBC driver, connection URL
- Update Kubernetes deployments: postgres:15 image, POSTGRES_* env vars, port 5432
- Update Kubernetes services: postgres-svc with port 5432
- Update ConfigMaps and Secrets: POSTGRES_DB, POSTGRES_PASSWORD, PostgreSQL JDBC URLs
- Update persistent volumes: /var/lib/postgresql/data mount path
- Update Helm charts: PostgreSQL configuration across StatefulSet, Service, ConfigMap, Secrets
- Update health checks: pg_isready instead of mysqladmin ping
- Update init containers: wait for postgres on port 5432

Database name 'BankDB' preserved. All JPA entities remain unchanged as they use
database-agnostic Spring Data JPA annotations.

All 17 configuration files updated:
- pom.xml, application.properties, docker-compose.yml
- kubernetes/: mysql-deployment.yml, mysql-service.yaml, configmap.yaml, secrets.yaml,
  bankapp-deployment.yml, persistent-volume.yaml, persistent-volume-claim.yaml
- helm/bankapp/: values.yaml, templates/mysqlStatefulSet.yml, templates/mysqlService.yml,
  templates/configMap.yml, templates/secrets.yml, templates/deployment.yml,
  templates/persistentVolume.yml

Requested by: Satwik Bebortha (@satwik-cog)
Devin run: https://app.devin.ai/sessions/7eed8ba1c24542939f702bd8fbb1f2be

Co-Authored-By: Satwik Bebortha <satwik.bebortha@cognition.ai>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

1 participant