Skip to content
Snippets Groups Projects
Verified Commit 625dd4b5 authored by Damien's avatar Damien
Browse files

FEAT #13671 TIME 0:35 Database creation fix structure

parent 209b59e7
No related branches found
No related tags found
No related merge requests found
...@@ -98,7 +98,7 @@ class InstallerController ...@@ -98,7 +98,7 @@ class InstallerController
if (!empty($queryParams['name'])) { if (!empty($queryParams['name'])) {
$name = $queryParams['name']; $name = $queryParams['name'];
$connection = "host={$queryParams['server']} port={$queryParams['port']} user={$queryParams['user']} password={$queryParams['password']} dbname={$queryParams['name']}"; $connection = "host={$queryParams['server']} port={$queryParams['port']} user={$queryParams['user']} password={$queryParams['password']} dbname={$queryParams['name']}";
$connected = !@pg_connect($connection); $connected = @pg_connect($connection);
} }
if (!$connected) { if (!$connected) {
$name = 'postgres'; $name = 'postgres';
...@@ -188,7 +188,7 @@ class InstallerController ...@@ -188,7 +188,7 @@ class InstallerController
return $response->withStatus(400)->withJson(['errors' => 'Body customName is empty or not a string']); return $response->withStatus(400)->withJson(['errors' => 'Body customName is empty or not a string']);
} }
if (!empty($body['alreadyCreated'])) { if (empty($body['alreadyCreated'])) {
$connection = "host={$body['server']} port={$body['port']} user={$body['user']} password={$body['password']} dbname=postgres"; $connection = "host={$body['server']} port={$body['port']} user={$body['user']} password={$body['password']} dbname=postgres";
if (!@pg_connect($connection)) { if (!@pg_connect($connection)) {
return $response->withStatus(400)->withJson(['errors' => 'Database connection failed']); return $response->withStatus(400)->withJson(['errors' => 'Database connection failed']);
...@@ -217,8 +217,8 @@ class InstallerController ...@@ -217,8 +217,8 @@ class InstallerController
if (!$fileContent) { if (!$fileContent) {
return $response->withStatus(400)->withJson(['errors' => 'Cannot read structure.sql']); return $response->withStatus(400)->withJson(['errors' => 'Cannot read structure.sql']);
} }
$result = $db->query($fileContent); $result = $db->exec($fileContent);
if (!$result) { if ($result === false) {
return $response->withStatus(400)->withJson(['errors' => 'Request failed : run structure.sql']); return $response->withStatus(400)->withJson(['errors' => 'Request failed : run structure.sql']);
} }
...@@ -227,8 +227,8 @@ class InstallerController ...@@ -227,8 +227,8 @@ class InstallerController
if (!$fileContent) { if (!$fileContent) {
return $response->withStatus(400)->withJson(['errors' => "Cannot read {$body['data']}.sql"]); return $response->withStatus(400)->withJson(['errors' => "Cannot read {$body['data']}.sql"]);
} }
$result = $db->query($fileContent); $result = $db->exec($fileContent);
if (!$result) { if ($result === false) {
return $response->withStatus(400)->withJson(['errors' => "Request failed : run {$body['data']}.sql"]); return $response->withStatus(400)->withJson(['errors' => "Request failed : run {$body['data']}.sql"]);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment