szurubooru/src/UpgradeService.php

30 lines
596 B
PHP
Raw Normal View History

<?php
namespace Szurubooru;
final class UpgradeService
{
private $db;
2014-08-30 17:10:45 +02:00
public function __construct(\Szurubooru\DatabaseConnection $databaseConnection)
{
2014-08-30 17:10:45 +02:00
$this->db = $databaseConnection->getDatabase();
}
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();
}
}