Skip to main content

Install

Git clone the repository:

git clone git@github.com:Monolith-FR/Monolith-API.git

Prerequisites

Load SQL Migrations

Because Flyway is brocken you should load the initial schema and then apply the migrations manually.

#!/bin/bash

DB_USER="root"
DB_PASS="root"
DB_NAME="monolith"
DB_HOST="127.0.0.1"
DB_PORT="3306"

SCHEMA_FILE="/root/Monolith-API/schema.sql"
MIGRATIONS_DIR="/root/Monolith-API/conf/old_migrations"

echo "[1/4] Dropping and recreating database..."
mysql -h $DB_HOST -P $DB_PORT -u $DB_USER -p$DB_PASS -e "DROP DATABASE IF EXISTS $DB_NAME; CREATE DATABASE $DB_NAME;"

echo "[2/4] Loading base schema.sql..."
mysql -h $DB_HOST -P $DB_PORT -u $DB_USER -p$DB_PASS $DB_NAME < $SCHEMA_FILE

echo "[3/4] Applying migrations manually..."
for f in $(ls $MIGRATIONS_DIR/V*.sql | sort); do
echo "🔄 Applying migration: $f"
mysql -h $DB_HOST -P $DB_PORT -u $DB_USER -p$DB_PASS $DB_NAME < "$f"
if [ $? -eq 0 ]; then
VERSION=$(basename "$f" | cut -d'_' -f1 | sed 's/^V//')
DESC=$(basename "$f" | cut -d'_' -f2- | sed 's/__/: /' | sed 's/.sql//')
echo "✅ Success: $f — registering version $VERSION"
mysql -h $DB_HOST -P $DB_PORT -u $DB_USER -p$DB_PASS $DB_NAME -e "
INSERT INTO flyway_schema_history (
installed_rank, version, description, type, script, installed_by, execution_time, success
) VALUES (
(SELECT IFNULL(MAX(installed_rank), 0) + 1 FROM flyway_schema_history),
'$VERSION',
'$DESC',
'SQL',
'$(basename "$f")',
'manual',
0,
1
);"
else
echo "❌ Failed: $f — skipping..."
fi
done

echo "[4/4] Done."

Run the API

sbt ~run