mirror of
https://github.com/silverstripe/silverstripe-postgresql
synced 2024-10-22 17:05:45 +02:00
API CHANGE: dev/tests/cleanupdb functionality now supported
This commit is contained in:
parent
2190c09c49
commit
113d75f825
@ -234,6 +234,15 @@ class PostgreSQLDatabase extends SS_Database {
|
||||
$this->query("DROP DATABASE $db_to_drop");
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop the database that this object is currently connected to.
|
||||
* Use with caution.
|
||||
*/
|
||||
public function dropDatabaseByName($dbName) {
|
||||
if($dbName!=$this->database)
|
||||
$this->query("DROP DATABASE \"$dbName\";");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the currently selected database
|
||||
*/
|
||||
@ -264,6 +273,13 @@ class PostgreSQLDatabase extends SS_Database {
|
||||
return $this->query("SELECT datname FROM pg_database WHERE datname='$SQL_name';")->first() ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a column
|
||||
*/
|
||||
public function allDatabaseNames() {
|
||||
return $this->query("SELECT datname FROM pg_database WHERE datistemplate=false;")->column();
|
||||
}
|
||||
|
||||
public function createTable($tableName, $fields = null, $indexes = null, $options = null, $extensions = null) {
|
||||
|
||||
$fieldSchemas = $indexSchemas = "";
|
||||
@ -1641,7 +1657,7 @@ class PostgreSQLDatabase extends SS_Database {
|
||||
$date = "TIMESTAMP '$date'";
|
||||
}
|
||||
|
||||
// ... when being too precise becomes a pain. We need to cut of the fractions.
|
||||
// ... when being too precise becomes a pain. we need to cut of the fractions.
|
||||
// TIMESTAMP(0) doesn't work because it rounds instead flooring
|
||||
return "CAST(SUBSTRING(CAST($date + INTERVAL '$interval' AS VARCHAR) FROM 1 FOR 19) AS TIMESTAMP)";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user