Skip to content

Commit

Permalink
#14862 - Refactor method clear() by adding support of Postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Feb 25, 2020
1 parent df71cf1 commit f59d6cb
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/_data/fixtures/Migrations/AbstractMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,25 @@ public function clear()
->connection
->getAttribute(PDO::ATTR_DRIVER_NAME)
;
if ('sqlite' !== $driver) {
if ($driver === 'mysql') {
$this->connection->exec(
'truncate table ' . $this->table . ';'
);
} else {
} elseif ($driver === 'sqlite') {
$this->connection->exec(
'delete from ' . $this->table . ';'
);
} else {
$schema = getenv('DATA_POSTGRES_SCHEMA');
$exists = $this
->connection
->query("SELECT to_regclass('$schema.$this->table') AS exists;")
->fetchColumn();
if ($exists) {
$this->connection->exec(
'truncate table ' . $this->table . ' cascade;'
);
}
}
}
}
Expand Down

0 comments on commit f59d6cb

Please sign in to comment.