feat: try fix migrations
This commit is contained in:
parent
6f5c8a6538
commit
e991c57055
|
|
@ -36,13 +36,32 @@ services:
|
||||||
DB_USERNAME: "${DB_USERNAME}"
|
DB_USERNAME: "${DB_USERNAME}"
|
||||||
DB_PASSWORD: "${DB_PASSWORD}"
|
DB_PASSWORD: "${DB_PASSWORD}"
|
||||||
|
|
||||||
# On attend que MySQL soit joignable avant de migrer
|
# On attend que MySQL soit prêt et on retente la migration jusqu'à succès
|
||||||
command: >
|
command: >
|
||||||
sh -c "
|
sh -c "
|
||||||
echo '⏳ Waiting for MySQL on mysql:3306...';
|
echo '⏳ Waiting for MySQL on mysql:3306...';
|
||||||
php -r 'while (!@fsockopen(\"mysql\", 3306)) { echo \"MySQL not ready, retrying...\n\"; sleep(2);}';
|
php -r '
|
||||||
|
$host = getenv(\"DB_HOST\") ?: \"mysql\";
|
||||||
|
$port = getenv(\"DB_PORT\") ?: \"3306\";
|
||||||
|
$db = getenv(\"DB_DATABASE\") ?: \"\";
|
||||||
|
$user = getenv(\"DB_USERNAME\") ?: \"\";
|
||||||
|
$pass = getenv(\"DB_PASSWORD\") ?: \"\";
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
new PDO(\"mysql:host={$host};port={$port};dbname={$db}\", $user, $pass);
|
||||||
|
break;
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
echo \"MySQL not ready: {$e->getMessage()}\\n\";
|
||||||
|
sleep(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
';
|
||||||
echo '✅ MySQL is up, running migrations...';
|
echo '✅ MySQL is up, running migrations...';
|
||||||
php artisan migrate --force --no-interaction
|
until php artisan migrate --force --no-interaction; do
|
||||||
|
echo '❌ Migration failed, retrying in 5s...';
|
||||||
|
sleep 5;
|
||||||
|
done;
|
||||||
|
echo '✅ Migrations applied.';
|
||||||
"
|
"
|
||||||
|
|
||||||
mysql:
|
mysql:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue