Unverified Commit f12f766d authored by Jens Segers's avatar Jens Segers Committed by GitHub

Merge pull request #1330 from NoelDeMartin/fix-1318

#1318 Implement dropping all tables with mongo driver
parents 5d55933a 8172bfb8
...@@ -106,6 +106,16 @@ class Builder extends \Illuminate\Database\Schema\Builder ...@@ -106,6 +106,16 @@ class Builder extends \Illuminate\Database\Schema\Builder
return $blueprint->drop(); return $blueprint->drop();
} }
/**
* @inheritdoc
*/
public function dropAllTables()
{
foreach ($this->getAllCollections() as $collection) {
$this->drop($collection);
}
}
/** /**
* @inheritdoc * @inheritdoc
*/ */
...@@ -113,4 +123,19 @@ class Builder extends \Illuminate\Database\Schema\Builder ...@@ -113,4 +123,19 @@ class Builder extends \Illuminate\Database\Schema\Builder
{ {
return new Blueprint($this->connection, $collection); return new Blueprint($this->connection, $collection);
} }
/**
* Get all of the collections names for the database.
*
* @return array
*/
protected function getAllCollections()
{
$collections = [];
foreach ($this->connection->getMongoDB()->listCollections() as $collection) {
$collections[] = $collection->getName();
}
return $collections;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment