Reputation: 835
I have two separate Laravel Homestead projects called "Laravel" and "authapp". I would like each of these projects to have their own database.
I have set up my Homestead.yaml file to create one database for each project. And it does just that. However, when I am in my "authapp" project and run the migrate command, it insists on writing to the database specified for the "Laravel" project (the "homestead" database).
Here is my Homestead.yaml file:
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Code/Laravel
to: /home/vagrant/Code/Laravel
- map: ~/Code/authapp
to: /home/vagrant/Code/authapp
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
- map: authapp.app
to: /home/vagrant/Code/authapp/public
databases:
- homestead
- authapp
And my database.php file for the "Laravel" project.
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'homestead'),
'username' => env('DB_USERNAME', 'homestead'),
'password' => env('DB_PASSWORD', 'secret'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
And my database.php file for the "authapp" project.
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'authapp'),
'username' => env('DB_USERNAME', 'homestead'),
'password' => env('DB_PASSWORD', 'secret'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
I have run vagrant provision a bunch of times and that doesn't do the trick.
Upvotes: 1
Views: 4456
Reputation: 717
Check that the database authapp
exist in MySQL. Also check your .env
file, in the root of the directory, to make sure that DB_DATABASE
has not accidentally been set.
Whenever you use env('VARIABLE_NAME', 'default value')
the VARIABLE_NAME
set in the .env
file will always override the string value passed in as the second parameter to the env()
function.
Upvotes: 2