Reputation: 1896
I have configured homestead and have my laravel site running on it. I have ssh'd into the box to run my migrations. When I did that, I realized, I will want to run more than one site on this VM as I'm learning laravel and homestead. So I wanted separate databases so I don't pile everything onto 'homestead'
I connected to the mysql database in the homestead vm with Sequel Pro and created a new database. I rolled back my migration to drop all tables on the homstead db, confirmed they were dropped in Sequel Pro. Then I updated my app/config/database.php file with the new database name:
'mysql' => array(
'driver' => 'mysql',
'host' => '127.0.0.1',
'database' => 'newDBName',
....
Then I ran my migrations on Homestead again, however it continues to put the tables in the 'homestead' database. I've done this a number of times, confirmed it was saving, updated other files and checked that files are syncing with the VM when they are edited locally (which they are). I have vagrant reload (ed) to see if that could cause it. No luck.
I'm at a loss. How can I force my laravel app to migrate and reference the new database I have created on Homestead?
Upvotes: 1
Views: 395
Reputation: 153070
Laravel offers the possibility to have config files for different environments that override the default. In case of a local development environment that would be app/config/local/database.php
. Make sure to change the database name in there.
This feature is extremely useful when the application is running in multiple environments and you don't have to worry about accidentally uploading the local configuration on a production server.
Upvotes: 2