/** * @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.'); } }
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'); }
/** * 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); } } }
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'); }
/** * 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(); }
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; } } }
/** * 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; } } }
/** * Check if a table exists * * @param string $table table name without the prefix * @return bool */ public function tableExists($table) { return $this->connection->tableExists($table); }
public function setup() { if (!$this->dbConnection->tableExists($this->sourceCalendarTable)) { throw new \DomainException('Calendar tables are missing. Nothing to do.'); } }