예제 #1
0
	/**
	 * @param string $table
	 */
	public function assertTableNotExist($table) {
		if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
			// sqlite removes the tables after closing the DB
			$this->assertTrue(true);
		} else {
			$this->assertFalse($this->connection->tableExists($table), 'Table ' . $table . ' doesnt exists.');
		}
	}
예제 #2
0
 public function testRun()
 {
     $this->assertFalse($this->connection->tableExists('sharing'), 'Asserting that the table oc_sharing does not exist before repairing');
     $this->assertTrue($this->connection->tableExists('permissions'), 'Asserting that the table oc_permissions does exist before repairing');
     $repair = new \OC\Repair\DropOldTables($this->connection);
     $repair->run();
     $this->assertFalse($this->connection->tableExists('sharing'), 'Asserting that the table oc_sharing does not exist after repairing');
     $this->assertFalse($this->connection->tableExists('permissions'), 'Asserting that the table oc_permissions does not exist after repairing');
 }
예제 #3
0
 /**
  * Run repair step.
  * Must throw exception on error.
  *
  * @throws \Exception in case of failure
  */
 public function run()
 {
     foreach ($this->oldDatabaseTables() as $tableName) {
         if ($this->connection->tableExists($tableName)) {
             $this->emit('\\OC\\Repair', 'info', [sprintf('Table %s has been deleted', $tableName)]);
             $this->connection->dropTable($tableName);
         }
     }
 }
예제 #4
0
 public function testRun()
 {
     $this->assertFalse($this->connection->tableExists('sharing'), 'Asserting that the table oc_sharing does not exist before repairing');
     $this->assertTrue($this->connection->tableExists('permissions'), 'Asserting that the table oc_permissions does exist before repairing');
     /** @var IOutput | \PHPUnit_Framework_MockObject_MockObject $outputMock */
     $outputMock = $this->getMockBuilder('\\OCP\\Migration\\IOutput')->disableOriginalConstructor()->getMock();
     $repair = new \OC\Repair\DropOldTables($this->connection);
     $repair->run($outputMock);
     $this->assertFalse($this->connection->tableExists('sharing'), 'Asserting that the table oc_sharing does not exist after repairing');
     $this->assertFalse($this->connection->tableExists('permissions'), 'Asserting that the table oc_permissions does not exist after repairing');
 }
예제 #5
0
 /**
  * Run repair step.
  * Must throw exception on error.
  *
  * @throws \Exception in case of failure
  */
 public function run(IOutput $output)
 {
     $tables = $this->oldDatabaseTables();
     $output->startProgress(count($tables));
     foreach ($this->oldDatabaseTables() as $tableName) {
         if ($this->connection->tableExists($tableName)) {
             $this->connection->dropTable($tableName);
         }
         $output->advance(1, "Drop old database table: {$tableName}");
     }
     $output->finishProgress();
 }
예제 #6
0
 public function __destruct()
 {
     try {
         $this->cleanEmptyLocks();
     } catch (\PDOException $e) {
         // If the table is missing, the clean up was successful
         if ($this->connection->tableExists('file_locks')) {
             throw $e;
         }
     }
 }
예제 #7
0
 /**
  * cleanup empty locks
  */
 public function cleanExpiredLocks()
 {
     $expire = $this->timeFactory->getTime();
     try {
         $this->connection->executeUpdate('DELETE FROM `*PREFIX*file_locks` WHERE `ttl` < ?', [$expire]);
     } catch (\Exception $e) {
         // If the table is missing, the clean up was successful
         if ($this->connection->tableExists('file_locks')) {
             throw $e;
         }
     }
 }
예제 #8
0
파일: db.php 프로젝트: farukuzun/core-1
 /**
  * Check if a table exists
  *
  * @param string $table table name without the prefix
  * @return bool
  */
 public function tableExists($table)
 {
     return $this->connection->tableExists($table);
 }
예제 #9
0
 public function setup()
 {
     if (!$this->dbConnection->tableExists($this->sourceCalendarTable)) {
         throw new \DomainException('Calendar tables are missing. Nothing to do.');
     }
 }