You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thrownewInvalidInputException(sprintf('Cannot use port %s as the local port for the SSH tunnel to the database server', $databaseServer->getDefaultPort()));
80
82
}
81
83
82
84
$this->output->info(sprintf('Opening SSH tunnel to the "<comment>%s</comment>" database server...', $databaseServer->getName()));
@@ -87,6 +89,6 @@ protected function openSshTunnel(DatabaseServer $databaseServer, int $localPort
87
89
thrownewResourceStateException(sprintf('The "%s" network doesn\'t have a bastion host to connect to, but you can add one to the network with the "%s" command', $databaseServer->getNetwork()->getName(), AddBastionHostCommand::NAME));
$this->output->info('Database user created successfully');
65
68
66
-
if (!$databaseUser->getDatabaseServer()->isPublic()) {
67
-
$this->output->newLine();
68
-
$this->output->important(sprintf('The "<comment>%s</comment>" database user needs to be manually created on the "<comment>%s</comment>" database server because it isn\'t publicly accessible. You can use the following queries to create it and grant it access to the server:', $databaseUser->getName(), $databaseUser->getDatabaseServer()->getName()));
69
-
$this->output->writeln(sprintf('CREATE USER %s@\'%%\' IDENTIFIED BY \'%s\'', $databaseUser->getName(), $databaseUser->getPassword()));
70
-
$this->output->writeln(sprintf('GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES ON *.* TO %s@\'%%\'', $databaseUser->getName()));
69
+
if ($databaseServer->isPublic()) {
70
+
return;
71
+
}
72
+
73
+
$this->output->newLine();
74
+
$this->output->important(sprintf('The "<comment>%s</comment>" database user needs to be manually created on the "<comment>%s</comment>" database server because it isn\'t publicly accessible. You can use the following queries to create it and grant it access to the server:', $databaseUser->getName(), $databaseServer->getName()));
75
+
76
+
switch ($databaseServer->getEngine()) {
77
+
case DatabaseServer::ENGINE_MYSQL:
78
+
$this->output->writeln(sprintf('CREATE USER %s@\'%%\' IDENTIFIED BY \'%s\'', $databaseUser->getName(), $databaseUser->getPassword()));
79
+
$this->output->writeln(sprintf('GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES ON *.* TO %s@\'%%\'', $databaseUser->getName()));
80
+
81
+
break;
82
+
case DatabaseServer::ENGINE_POSTGRESQL:
83
+
$this->output->writeln(sprintf('CREATE USER "%s" WITH PASSWORD \'%s\'', $databaseUser->getName(), $databaseUser->getPassword()));
84
+
$this->output->writeln(sprintf('GRANT "%s" TO CURRENT_USER', $databaseUser->getName()));
85
+
$this->output->writeln(sprintf('GRANT ALL PRIVILEGES ON DATABASE "<database>" TO "%s"', $databaseUser->getName()));
$this->output->important('The database user needs to be manually deleted on the database server because it isn\'t publicly accessible. You can use the following query to delete it:');
62
-
$this->output->writeln(sprintf('DROP USER IF EXISTS %s@\'%%\'', $databaseUser->getName()));
60
+
if ($databaseServer->isPublic()) {
61
+
return;
62
+
}
63
+
64
+
$this->output->newLine();
65
+
$this->output->important('The database user needs to be manually deleted on the database server because it isn\'t publicly accessible. You can use the following query to delete it:');
66
+
67
+
switch ($databaseServer->getEngine()) {
68
+
case DatabaseServer::ENGINE_MYSQL:
69
+
$this->output->writeln(sprintf('DROP USER IF EXISTS %s@\'%%\'', $databaseUser->getName()));
70
+
71
+
break;
72
+
case DatabaseServer::ENGINE_POSTGRESQL:
73
+
$this->output->writeln(sprintf('DROP USER IF EXISTS "%s"', $databaseUser->getName()));
0 commit comments