8000 [8.x] Add DB command to drop into the database CLI by paras-malhotra · Pull Request #35304 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content

[8.x] Add DB command to drop into the database CLI #35304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 21, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
8000
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
formatting
  • Loading branch information
paras-malhotra committed Nov 20, 2020
commit a6385ce2d7a33c76d58af919152c1dd911700af9
50 changes: 25 additions & 25 deletions src/Illuminate/Database/Console/DbCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function getConnection()
* @param array $connection
* @return array
*/
public function getArgs($connection)
public function getArgs(array $connection)
{
$driver = ucfirst($connection['driver']);

Expand All @@ -78,7 +78,7 @@ public function getArgs($connection)
* @param array $connection
* @return array|null
*/
public function getEnv($connection)
public function getEnv(array $connection)
{
$driver = ucfirst($connection['driver']);

Expand All @@ -95,13 +95,13 @@ public function getEnv($connection)
* @param array $connection
* @return string
*/
public function getCommand($connection)
public function getCommand(array $connection)
{
return [
'mysql' => 'mysql',
'pgsql' => 'psql',
'sqlite' => 'sqlite3',
'sqlsrv' => 'sqlcmd',
'mysql' => 'mysql',
'pgsql' => 'psql',
'sqlite' => 'sqlite3',
'sqlsrv' => 'sqlcmd',
][$connection['driver']];
}

Expand All @@ -111,16 +111,16 @@ public function getCommand($connection)
* @param array $connection
* @return array
*/
protected function getMysqlArgs($connection)
protected function getMysqlArgs(array $connection)
{
return array_merge([
'--host='.$connection['host'],
'--port='.$connection['port'],
'--user='.$connection['username'],
], $this->buildOptionalArguments([
'password' => '--password='.$connection['password'],
'unix_socket' => '--socket='.$connection['unix_socket'],
'charset' => '--default-character-set='.$connection['charset'],
'password' => '--password='.$connection['password'],
'unix_socket' => '--socket='.$connection['unix_socket'],
'charset' => '--default-character-set='.$connection['charset'],
], $connection), [$connection['database']]);
}

Expand All @@ -130,7 +130,7 @@ protected function getMysqlArgs($connection)
* @param array $connection
* @return array
*/
protected function getPgsqlArgs($connection)
protected function getPgsqlArgs(array $connection)
{
return [$connection['database']];
}
Expand All @@ -141,7 +141,7 @@ protected function getPgsqlArgs($connection)
* @param array $connection
* @return array
*/
protected function getSqliteArgs($connection)
protected function getSqliteArgs(array $connection)
{
return [$connection['database']];
}
Expand All @@ -152,14 +152,14 @@ protected function getSqliteArgs($connection)
* @param array $connection
* @return array
*/
protected function getSqlsrvArgs($connection)
protected function getSqlsrvArgs(array $connection)
{
return $this->buildOptionalArguments([
'database' => '-d '.$connection['database'],
'username' => '-U '.$connection['username'],
'password' => '-P '.$connection['password'],
'host' => '-S tcp:'.$connection['host']
.($connection['port'] ? ','.$connection['port'] : ''),
'database' => '-d '.$connection['database'],
'username' => '-U '.$connection['username'],
'password' => '-P '.$connection['password'],
'host' => '-S tcp:'.$connection['host']
.($connection['port'] ? ','.$connection['port'] : ''),
], $connection);
}

Expand All @@ -169,13 +169,13 @@ protected function getSqlsrvArgs($connection)
* @param array $connection
* @return array|null
*/
protected function getpgsqlEnv($connection)
protected function getpgsqlEnv(array $connection)
{
return array_merge(...$this->buildOptionalArguments([
'username' => ['PGUSER' => $connection['username']],
'host' => ['PGHOST' => $connection['host']],
'port' => ['PGPORT' => $connection['port']],
'password' => ['PGPASSWORD' => $connection['password']],
'username' => ['PGUSER' => $connection['username']],
'host' => ['PGHOST' => $connection['host']],
'port' => ['PGPORT' => $connection['port']],
'password' => ['PGPASSWORD' => $connection['password']],
], $connection));
}

Expand All @@ -186,7 +186,7 @@ protected function getpgsqlEnv($connection)
* @param array $connection
* @return array
*/
protected function buildOptionalArguments($args, $connection)
protected function buildOptionalArguments(array $args,array $connection)
{
return array_values(array_filter($args, function ($key) use ($connection) {
return ! empty($connection[$key]);
Expand Down
0