I have multiple hosting server for example : central_db, hosting_1, hosting_2, hosting_3 etc..
This hosting_1, hosting_2, hosting_3 details are saved on central_db database in mysql_servers table.
Now, I need to run this
php artisan migrate
command to create a tables to multiple hosting servers.
Now, I need to run this command to create a feed_mappings table to all hosting server .
So, What I am running is this:
// Get all mysql servers
$mysql_servers = DB::table('mysql_servers')->get();
if( $mysql_servers ) {
foreach($mysql_servers as $server ) {
if( ! Schema::connection($server->mysql_db_name)->hasTable('feed_mappings') ) {
Schema::connection($server->mysql_db_name)->create('feed_mappings', function (Blueprint $table) {
$table->bigIncrements('id_feed_mappings')->index();
$table->bigInteger('id_feed');
$table->string('id_project', 255);
$table->string('import_field_slug', 155);
$table->string('internal_field_slug', 155)->nullable();
$table->tinyInteger('import');
$table->tinyInteger('custom_field')->nullable();
$table->dateTime('date_add');
$table->dateTime('date_upd');
});
}
}
}
But it's not creating any table to different hosting server. Is anything I am doing wrong? How can I solve it?