I want to upgrade multiple schemas on a legacy system running on a single mysql instance.
In development I have ~10 schemas, while in production I have ~100 schemas.
In development I was using a simple bash loop to start a flyway migrate
for each schema:
schemas=$(echo "SET SESSION group_concat_max_len=8192; select GROUP_CONCAT(SCHEMA_NAME SEPARATOR ' ') from information_schema.SCHEMATA where SCHEMA_NAME like 'FOO_%'" | mysql -h$DB_URL -P$DB_PORT -u$DB_USER -p$DB_PASSWORD -sN)
for schema in $schemas; do
echo "Starting Migration for : $schema"
flyway -configFile=src/flyway.conf -user=$DB_USER -password=$DB_PASSWORD -url="jdbc:mysql://$DB_URL:$DB_PORT" -schemas=$schema -locations=filesystem:src/schema/ migrate 2>&1 | tee $schema.log &
done
This strategy was working fine in dev. In production I quickly max out the ram of the gitlab runner that runs the flyway migrate
.
In your opinion what would be the best way to acheive the database migration as fast as possible without maxing out the ram?