Skip to content

Commit db89ad5

Browse files
authored
Allow connecting to read or write connections with the db command (#37548)
1 parent 7ad6ba2 commit db89ad5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Illuminate/Database/Console/DbCommand.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ class DbCommand extends Command
1414
*
1515
* @var string
1616
*/
17-
protected $signature = 'db {connection? : The database connection that should be used}';
17+
protected $signature = 'db {connection? : The database connection that should be used}
18+
{--read : Connect to the read connection}
19+
{--write : Connect to the write connection}';
1820

1921
/**
2022
* The console command description.
@@ -64,6 +66,12 @@ public function getConnection()
6466
$connection = (new ConfigurationUrlParser)->parseConfiguration($connection);
6567
}
6668

69+
if ($this->option('read')) {
70+
$connection = array_merge($connection, $connection['read']);
71+
} elseif ($this->option('write')) {
72+
$connection = array_merge($connection, $connection['write']);
73+
}
74+
6775
return $connection;
6876
}
6977

0 commit comments

Comments
 (0)