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

Fixes #209 - Impossible to run platform services on a shared database #212

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

andrea-gioia
Copy link
Contributor

Fix Impossible to run platform services on a shared database (#209)

What does this PR do?

This pull request adds the flyway. schemas property to the docker application profile of each platform service to save the flyway_schema_history table in the same schema used by the service and not in the public schema. This prevents conflict and fixes the issue of running multiple platform services on a shared database.

Changes made:

How to test:

Build code...

git clone git@github.com:opendatamesh-initiative/odm-platform.git
cd ./odm-platform
mvn clean install -DskipTests

Run Postgres container...

docker network create odmp-network
docker run --name odmp-postgres -d --network odmp-network -p 5432:5432 \
  -e POSTGRES_DB=odmpdb \
  -e POSTGRES_USER=postgres \
  -e POSTGRES_PASSWORD=postgres \
  postgres:11-alpine

Run registry container...

docker build -t odmp-postgres-registry . -f product-plane-services/registry-server/Dockerfile \
   --build-arg DATABASE_URL=jdbc:postgresql://odmp-postgres:5432/odmpdb \
   --build-arg DATABASE_USERNAME=postgres \
   --build-arg DATABASE_PASSWORD=postgres \
   --build-arg FLYWAY_SCRIPTS_DIR=postgresql


docker run --name odmp-postgres-registry  -d --network odmp-network -p 8001:8001 odmp-postgres-registry

Run notification container...

  docker build -t odmp-postgres-notification . -f product-plane-services/notification-server/Dockerfile\
   --build-arg DATABASE_URL=jdbc:postgresql://odmp-postgres:5432/odmpdb \
   --build-arg DATABASE_USERNAME=postgres \
   --build-arg DATABASE_PASSWORD=postgres \
   --build-arg FLYWAY_SCRIPTS_DIR=postgresql


docker run --name odmp-postgres-notification  -d --network odmp-network -p 8006:8006 odmp-postgres-notification

Restart containers...

docker stop odmp-postgres-registry
docker stop odmp-postgres-notification
docker start odmp-postgres-registry
docker start odmp-postgres-notification

The restart of services MUST be completed successfully.

🔴 WARNING 🔴 Before running the new version of a service during an upgrade, the existing flyway_schema_history table must be copied from the previous schema (typically public) to the specific schema used by the service. For example, for the registry service, the following instruction should be executed in PostgreSQL to replicate the flyway_schema_history table within the ODMREGISTRY schema

create table "ODMREGISTRY"."flyway_schema_history" as select * from "public"."flyway_schema_history" 

@andrea-gioia andrea-gioia linked an issue Jan 25, 2025 that may be closed by this pull request
@andrea-gioia andrea-gioia requested a review from aliprax January 25, 2025 15:17
@andrea-gioia andrea-gioia added the bug Something isn't working label Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Impossible to run platform services on a shared database
3 participants