Update:
I suspected that my issue may have to do with the fact that I have previously "squashed" a load of old migration files into a single schema file. After deleting this file the migration kicks off successfully (though ultimately fails due to many tables missing). So as it appears, Vapor is unusable for anyone who has previously ran php artisan schema:dump --prune which is definitely a bummer...
Laravel Vapor: mysql not found
Hey everyone,
I am working on setting up my existing Laravel 8 application on Vapor today and have run into an issue I can't seem to find anything about online.
I have installed the vapor-cli and vapor-core packages. Connected my AWS account, created a project and RDS database. Everything seems to be working up until the point I attempt to perform the initial migration of the database. It appears that the mysql command is not found?
Hook: migrate:fresh --seed
Dropped all tables successfully.
Migration table created successfully.
Loading stored database schema: /var/task/database/schema/mysql-schema.dump
Symfony\Component\Process\Exception\ProcessFailedException
The command "mysql --user="${:LARAVEL_LOAD_USER}" --password="${:LARAVEL_LOAD_PASSWORD}" --host="${:LARAVEL_LOAD_HOST}" --port="${:LARAVEL_LOAD_PORT}" --database="${:LARAVEL_LOAD_DATABASE}" < "${:LARAVEL_LOAD_PATH}"" failed.
Exit Code: 127(Command not found)
Working directory: /var/task
Output:
================
Error Output:
================
sh: mysql: command not found
at vendor/symfony/process/Process.php:272
268▕ */
269▕ public function mustRun(callable $callback = null, array $env = []): self
270▕ {
271▕ if (0 !== $this->run($callback, $env)) {
➜ 272▕ throw new ProcessFailedException($this);
273▕ }
274▕
275▕ return $this;
276▕ }
+30 vendor frames
31 artisan:43
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
I have tried running artisan migrate:fresh --seed from both the vapor CLI as well as the vapor UI both with the same result.
I have also provided the command as a deployment hook with the same effect.
id: 30012
name: my-app
environments:
production:
memory: 1024
cli-memory: 512
runtime: 'php-8.1:al2'
build:
- 'COMPOSER_MIRROR_PATH_REPOS=1 composer install --no-dev'
- 'php artisan event:cache'
- 'npm ci && npm run prod && rm -rf node_modules'
staging:
database: 'my-app-db'
memory: 1024
cli-memory: 512
runtime: 'php-8.1:al2'
deploy:
- 'php artisan migrate:fresh --seed'
build:
- 'COMPOSER_MIRROR_PATH_REPOS=1 composer install'
- 'php artisan event:cache'
- 'npm ci && npm run dev && rm -rf node_modules'
(note i am only trying to deploy the staging environment php vendor/bin/vapor deploy staging)
Otherwise everything else seems to be working fine. Has anyone else encountered this issue?
Workaround:
If anyone else experiences this issue there is a way to work around the issue of the squashed Laravel migrations.
Assuming you are working locally, ensure your currently connected DB is in the exact state you would like.
Install this package https://github.com/kitloong/laravel-migrations-generator.
Delete all migration files as well as the schema dump file.
Clear your migrations table in the DB.
Run php artisan migrate:generate --squash to generate a proper Laravel migration file that reconstructs your entire CURRENT database schema.
Run vendor/bin/sail migrate:refresh (assuming you are using sail) to drop all tables and perform a fresh migration using the new migration file.
Once I did this i was able to run migrations for my Laravel Vapor enviroments.
Hope this helps somebody!
Please or to participate in this conversation.