Commit 1f2c88fd authored by Noel De Martin's avatar Noel De Martin

#1318 Implement dropping all tables with mongo driver

parent 8c17827d
...@@ -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,21 @@ class Builder extends \Illuminate\Database\Schema\Builder ...@@ -113,4 +123,21 @@ 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