0

without using my config/database.php in mysql connection.

to use my config/newdatabase.php in newsql connection.

example command such as blow.

php artisan migrate database=newsql

Thanks.

Tamil
  • 311
  • 4
  • 9
  • You're close, it's `php artisan migrate --database=newsql` but you need to define it as a connection in your `database.php` – apokryfos Oct 25 '20 at 07:16
  • Any other way using my config file connection. – Tamil Oct 25 '20 at 08:04
  • 1
    Not from the command-line no. In code you can do something like `config([ 'database.connections' => array_merge(config('database.connections'), config('newdatabase.connections')) ])` and it should merge the connections defined in each file – apokryfos Oct 25 '20 at 08:06
  • make your own command through artisan? – Tamil Oct 25 '20 at 08:11
  • You can add this code in a service provider (maybe do a `if (app()->runningInConsole())` first if you only want to restrict it to console commands) – apokryfos Oct 25 '20 at 08:14

1 Answers1

0

It would be better to define a new .env file instead of a second config file with database info. Laravel just won't recognize the second config file, it'll be troublesome.

Create a file called .env.newsettings, update your database settings, than run: php artisan migrate --env=newsettings

Maarten Veerman
  • 1,546
  • 1
  • 8
  • 10