I'm working on an app with multiple database connections. It seems when I run php artisan migrate:install it always creates the migrations table using my default connection in app/config/database.php, which is not ideal.
Is there a way to specify a different connection for the migrations table itself?
Laravel makes connecting with databases and running queries extremely simple. The database configuration file is app/config/database. php . In this file you may define all of your database connections, as well as specify which connection should be used by default.
Echo the Laravel database name in Blade/PHP The simplest way it to place the following script in a Blade or PHP file. This will output the name of the database or return 'none' if there is no connection. If you view it in the browser, it gives you the name of the connected database.
To run the specific migration in Laravel, you need to use --path option with the php artisan migrate command. Let's take a simple example, we have '2019_12_04_131405_create_payments_table. php' migration in the database/migrations directory and we would like to run this migration.
For anyone with a similar question, I found a better answer.
Looks like you can't specify the connection from a config file or anything, but you can when you run migrate from the command line...
php artisan migrate:install --database=NAME_OF_CONNECTION
There is one caveat: anytime you run an actual migration you must also specify the database connection with --database
again or it will re-create the migrations table using the default connection.
Edit: Looks like you want to change where the migrations table is stored. This I believe always uses the default. You can however specify where a table is supposed to be created as below:
You can specify a connection like so:
Schema::connection('foo')->create('users', function($table)
{
$table->increments('id');
});
From http://laravel.com/docs/schema
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With