Laravel migration with mysql client
ilvalerione
PROOP

2 months ago

My Laravel application try to use the "mysql" command line to perform migrations. It is the case because I have squashed my migrations, and Laravel try to run the SQL script to create the database structure with mysql cli command.

Obviously it's not available in the railway service pod, so the deployment fails.

Laravel doesn't have an option to run this kind of schema setup in a different way. Do you have a workaround?

Thank you for the support.

Attachments

$10 Bounty

1 Replies

ilvalerione
PROOP

2 months ago

I solved creating a custom artisan command to run the statement below:

DB::unprepared(file_get_contents(database_path('schema/mysql-schema.sql')));
  • I removed the migration command from the start script

  • SSHing into the service container with railway CLI

  • run the command "php artisan database-import"

  • Restore "php artisan migrate" in the init-app.sh start script

Subsequent deployments will run the standard Laravel migration command as usual without using the mysql cli.


Loading...