2014-08-28 10:45:55 +02:00
|
|
|
<?php
|
|
|
|
namespace Szurubooru;
|
|
|
|
|
|
|
|
final class UpgradeService
|
|
|
|
{
|
|
|
|
private $db;
|
|
|
|
|
2014-08-30 17:10:45 +02:00
|
|
|
public function __construct(\Szurubooru\DatabaseConnection $databaseConnection)
|
2014-08-28 10:45:55 +02:00
|
|
|
{
|
2014-08-30 17:10:45 +02:00
|
|
|
$this->db = $databaseConnection->getDatabase();
|
2014-08-28 10:45:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function prepareForUsage()
|
|
|
|
{
|
|
|
|
$this->db->createCollection('posts');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function removeAllData()
|
|
|
|
{
|
|
|
|
foreach ($this->db->getCollectionNames() as $collectionName)
|
|
|
|
$this->removeCollectionData($collectionName);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function removeCollectionData($collectionName)
|
|
|
|
{
|
|
|
|
$this->db->$collectionName->remove();
|
|
|
|
$this->db->$collectionName->deleteIndexes();
|
|
|
|
}
|
|
|
|
}
|