I am experiencing the following scenario:
I want to split my database into separate read and write databases. For that reason i've setup the config/database.php
'mysql' => [
'driver' => 'mysql',
'write' => ['host' => env('DB_HOST_WRITE', 'localhost'),],
'read' => ['host' => env('DB_HOST_READ', 'localhost'),],
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
For DB_HOST_WRITE
and DB_HOST_READ
I've set the IP addresses for the servers where the databases are running on.
For DB_DATABASE
, DB_USERNAME
, DB_PASSWORD
I've setup the database name and the login credentials.
Both servers are reachable, when I try to access them using mysql console commands like this: mysql -u USERNAME -h IPADDRESS -p
Here is the problem: When I attempt to run my migrations from a third server like this
php artisan migrate
But only the write database gets set up.
Is this the expected behaviour?
Do I have to migrate each database manually?
Is there a flag for the migration command, that allows me to specify the connection i want to migrate on?
I cant find anything about read write database migrations when I google for it.
There was no further database setup done. My information source is the following guide: https://laravel.com/docs/5.7/database#read-and-write-connections
Links to useful guides or solution suggestions are very welcome.
Thanks for your attention.