0

I am currently using Laravel 5.4. I have a separate database per client. I would like to run database migrations in all my client databases. The database names are in the format of clientdb_{clientid}. I have tried using

Config::set("database.connections.mysql", ["database" =>
 "clientdb_".$client['id'],
"username" => "root","password" => ""]);

 $this->callSilent('migrate', 
[ '--path' => 'database/migrations/clients','--database'=>'clientdb_'.$client['id']]);

but I am getting exception called

[InvalidArgumentException] Database [clientdb_1] not configured.

2 Answers 2

1

The code you show is configuring the connection labelled mysql. I think what you are really trying to do is configure a new database connection called clientdb_1:

Config::set("database.connections.clientdb_" . $client['id'], [
    "database" => "clientdb_" . $client['id'],
    "username" => "root",
    "password" => ""
]);
Sign up to request clarification or add additional context in comments.

5 Comments

in mysql driver i have configured the db called syncclient. but i would like to access dynamically using config::set aremy clientdb's
@ganesh Sorry, I don't understand. Is this a new question? Does my answer help with the question you asked initially?
this is the same question. scenario:: I have 1db per client. i want to access the client db's without configuring it in the config/database.php file i would like to access all the database is there anyway???
@ganesh I have answered that question.
is there anyway i would like to access without configuring in database.php file @Don't Panic
0

Looks like the database is not configured in your config/database.php file

1 Comment

yeah i have configured a permanent db in env and database.php. but these are runtime db i would like to access. how to make it possible @Abhishek Vyas

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.