问题
Right now I am building few social networks each having its own domain and database called content and a single common user database that is connected to all of them.
The question is - can I place the migration data concerning users into the users' database, so that every time updates to database are implemented via
php artisan migrate
on each of the social networks, - those would only apply to user database only once.
回答1:
I have done this on a project in the past, but you need to be careful with the Artisan commands you run.
Working with your example I would do the following;
app/database/migrations/users
- Migrations for your user database live hereapp/database/migrations/content
- Migrations for your content database live here
You will also need to create appropriate database connections to your config;
In app/config/database.php
;
<?php
return [
'connections' => [
'users' => [
// Usual database connection details here
],
'content_site1' => [
// Usual database connection details here
],
'content_site2' => [
// Usual database connection details here
]
]
];
Once you have this all configured you should be able to run php artisan migrate --path app/database/migrations/users --database users
to migrate your users database, and php artisan migrate --path app/database/migrations/content --database content_site1
for your content site. Remember change the database param for each connection you want to run the migration on.
来源:https://stackoverflow.com/questions/28339663/can-i-place-two-migration-tables-in-different-databases-when-using-laravel