mirror of
https://github.com/silverstripe/silverstripe-postgresql
synced 2024-10-22 15:05:45 +00:00
ENHANCEMENT Fixes to PostgreSQLDatabaseConfigurationHelper to support the installer changes in r99001
This commit is contained in:
parent
459d1ffe60
commit
bcd163ff06
@ -83,6 +83,9 @@ class PostgreSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelp
|
||||
/**
|
||||
* Ensure that the database connection is able to use an existing database,
|
||||
* or be able to create one if it doesn't exist.
|
||||
*
|
||||
* Unfortunately, PostgreSQLDatabase doesn't support automatically creating databases
|
||||
* at the moment, so we can only check that the chosen database exists.
|
||||
*
|
||||
* @param array $databaseConfig Associative array of db configuration, e.g. "server", "username" etc
|
||||
* @return array Result - e.g. array('success' => true, 'alreadyExists' => 'true')
|
||||
@ -90,6 +93,7 @@ class PostgreSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelp
|
||||
public function requireDatabaseOrCreatePermissions($databaseConfig) {
|
||||
$success = false;
|
||||
$alreadyExists = false;
|
||||
$canCreate = false;
|
||||
|
||||
$check = $this->requireDatabaseConnection($databaseConfig);
|
||||
$conn = $check['connection'];
|
||||
@ -98,17 +102,13 @@ class PostgreSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelp
|
||||
if(pg_fetch_array($result)) {
|
||||
$success = true;
|
||||
$alreadyExists = true;
|
||||
} else {
|
||||
if(@pg_query($conn, "CREATE DATABASE testing123")) {
|
||||
pg_query($conn, "DROP DATABASE testing123");
|
||||
$success = true;
|
||||
$alreadyExists = false;
|
||||
}
|
||||
$canCreate = true;
|
||||
}
|
||||
|
||||
return array(
|
||||
'success' => $success,
|
||||
'alreadyExists' => $alreadyExists
|
||||
'alreadyExists' => $alreadyExists,
|
||||
'canCreate' => $canCreate
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user