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 #207 - MySQL Flyway V2 migration for registry service #208

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andrea-gioia
Copy link
Contributor

Fix MySQL Flyway V2 migration for registry service (#207)

What does this PR do?

This pull request fixes the incorrect Flyway V2 migration script in the registry service.

Changes made:

  • In file product-plane-services/registry-server/src/main/resources/db/migration/mysql/V2__fix_foreign_keys.sql...
    • Removed " as table delimiter
    • Fixed some misspelled drop statement

How to test:

execute the following script to run the registry service on MySQL

#!/bin/bash

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

# Create the network only if it does not exist
if ! docker network inspect odmp-network >/dev/null 2>&1; then
  echo "Creating network 'odmp-network'..."
  docker network create odmp-network
else
  echo "Network 'odmp-network' already exists."
fi


# RUN MYSQL

# Remove the existing container if it exists
if docker ps -a --format '{{.Names}}' | grep -Eq "^odmp-mysql-db\$"; then
  echo "Removing existing container 'odmp-postgres-db'..."
  docker rm -f odmp-mysql-db
else
  echo "No existing container 'odmp-mysql-db' found."
fi

# Run the PostgreSQL container
echo "Starting new container 'odmp-mysql-db'..."
docker run --name odmp-mysql-db -d --network odmp-network -p 3306:3306  \
   -e MYSQL_ROOT_PASSWORD=root \
   mysql:8


# RUN ODM REGISTR

# Remove the existing container if it exists
if docker ps -a --format '{{.Names}}' | grep -Eq "^odmp-registry-mys\$"; then
  echo "Removing existing container 'odmp-registry-mys'..."
  docker rm -f odmp-registry-mys
else
  echo "No existing container 'odmp-registry-mys' found."
  pwd
fi

echo "Creating database ODMREGISTRY..."
docker exec -it odmp-mysql-db mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS ODMREGISTRY;"

echo "Building image odmp-registry-mys...."
docker build -t odmp-registry-mys . -f product-plane-services/registry-server/Dockerfile \
   --build-arg DATABASE_URL=jdbc:mysql://odmp-mysql-db:3306/ODMREGISTRY \
   --build-arg DATABASE_USERNAME=root \
   --build-arg DATABASE_PASSWORD=root \
   --build-arg FLYWAY_SCRIPTS_DIR=mysql

echo "Running containe odmp-registry-mys...."
docker run --name odmp-registry-mys  -d --network odmp-network -p 8001:8001 odmp-registry-mys

echo "Connect here to test the container [http://localhost:8001/api/v1/pp/registry/swagger-ui/index.html]"

Check that the odmp-registry-mys run correctly connecting at http://localhost:8001/api/v1/pp/registry/swagger-ui/index.html

Fixes #207.

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.

MySQL Flyway V2 migration of registry service is not correct
3 participants