Checks which tables of the db changed and then restores these tables.
Uses dump file '/tmp/tmp_db_dump' for comparison and restoring.

@param string $dumpName
178777
public function restoreDB($dumpName = 'test')
    {
        $this->setDumpName($dumpName);
        $tables = $this->getDbTables();

        $dumpChecksum = $this->getDumpChecksum();
        $dumpTables = array_keys($dumpChecksum);

        foreach ($tables as $table) {
            if (!in_array($table, $dumpTables)) {
                $this->dropTable($table);
            } else {
                $this->restoreTable($table);
            }
        }

        $missingTables = array_diff($dumpTables, $tables);
        foreach ($missingTables as $table) {
            $this->restoreTable($table);
        }
        $this->setDumpName('test');
    }
293854
public function getTables($dbName = '')
    {
        $sql    = !empty($dbName) ? 'SHOW TABLES FROM ' . $dbName : 'SHOW TABLES ';
        $pdo    = $this->query($sql, [], false, true);
        $result = $pdo->fetchAll(PDO::FETCH_ASSOC);
        $info   = [];

        foreach ($result as $key => $val) {
            $info[$key] = current($val);
        }

        return $info;
    }
521389
public function dumpDB($dumpName = 'test')
    {
        $this->setDumpName($dumpName);
        $tables = $this->getDbTables();

        foreach ($tables as $table) {
            $databaseHandler = $this->getDatabaseHandler();
            $directory = $this->getDumpDirectory();
            $databaseHandler->export($directory . '/' . $table . '.sql', array($table));
        }
        $this->saveChecksum($this->getTableChecksum($tables));
    }
369699
public function hasTable($tableName)
    {
        if ($tableName instanceof Model) {
            $tableName = $tableName->tableName();
        }

        return $this->connection->getSchemaManager()->tablesExist([$tableName]);
    }
266627
public function renameCheck($oldName, $newName)
    {
        if (!$this->hasCheck($oldName)) {
            throw SchemaException::tableCheckDoesNotExist($this->getName(), $oldName);
        }

        if ($this->hasCheck($newName)) {
            throw SchemaException::tableCheckAlreadyExists($this->getName(), $newName);
        }

        $this->checks[$oldName]->setName($newName);
        $this->checks[$newName] = $this->checks[$oldName];
        unset($this->checks[$oldName]);
    }
251972
protected function tableExists($tableName) {
		if(isset($this->nonExistingTables[$tableName]))
			return false;
		if(isset($this->existingTables[$tableName]))
			return true;
		$exists = $this->schemaManager->tablesExist(array(
			$tableName 
		));
		if(!$exists) {
			$this->nonExistingTables[$tableName] = 1;
		} else {
			$this->existingTables[$tableName] = 1;
		}
		return $exists;
	}
750616
public function restoreTable($table, $restoreColumns = false)
    {
        $dumpChecksum = $this->getDumpChecksum();
        $checksum = $this->getTableChecksum($table);
        if ($checksum[$table] === $dumpChecksum[$table]) {
            return;
        }

        $database = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster();
        if ($database->getOne("SHOW TABLES LIKE '$table'")) {
            $database->execute("DROP TABLE `$table`");
        }

        $databaseHandler = $this->getDatabaseHandler();
        $directory = $this->getDumpDirectory();
        $databaseHandler->import($directory . '/' . $table . '.sql');
    }
79568
protected static function initSessionStorage(string $dbName) : void
    {
        if (!isset($_SESSION['databases']) || !\is_array($_SESSION['databases'])) {
            $_SESSION['databases'] = [];
        }

        if (!isset($_SESSION['databases'][$dbName]) || !\is_array($_SESSION['databases'][$dbName])) {
            $_SESSION['databases'][$dbName] = ['tables' => []];
        }
    }
624327
public function hasView($tableName)
    {
        $dbMetadata = Source\Factory::createSourceFromAdapter($this->db);
        $tableNames = $dbMetadata->getViewNames();

        return in_array($tableName, $tableNames);
    }
378594
public static function dropTemporaryTable(string $tableName): void
  {
    $query = sprintf('drop temporary table `%s`', $tableName);

    self::executeNone($query);
  }
1105098
public function clearTable(string $tableName): bool
    {
        $delete = new DeleteQuery($this->db);

        return $delete->from($tableName)->execute();
    }
273371
public function restoreTable($table, $restoreColumns = false)
    {
        $dumpChecksum = $this->getDumpChecksum();
        $checksum = $this->getTableChecksum($table);
        if ($checksum[$table] === $dumpChecksum[$table]) {
            return;
        }

        $file = $this->getDumpFolderPath() .'/'. $table ."_dump.sql";

        if (file_exists($file)) {
            $database = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster();
            $database->execute("TRUNCATE TABLE `$table`");

            $query = "LOAD DATA INFILE '$file' INTO TABLE `$table`";
            $database->execute($query);
        }
    }
451795
public function checkTableExists(string $tableName): bool
    {
        try {
            $result = $this->pdo->query("SELECT 1 FROM $tableName LIMIT 1");
        } catch (\Exception $e) {
            return false;
        }

        return $result !== false;
    }
394569
public function fixTableCase($tableName)
    {
        // Check if table exists
        $tables = $this->tableList();
        if (!array_key_exists(strtolower($tableName), $tables)) {
            return;
        }

        // Check if case differs
        $currentName = $tables[strtolower($tableName)];
        if ($currentName === $tableName) {
            return;
        }

        $this->alterationMessage(
            "Table $tableName: renamed from $currentName",
            "repaired"
        );

        // Rename via temp table to avoid case-sensitivity issues
        $tempTable = "__TEMP__{$tableName}";
        $this->renameTable($currentName, $tempTable);
        $this->renameTable($tempTable, $tableName);
    }
1106351
protected function tableExist($tableName)
    {
        /** @var \Doctrine\DBAL\Schema\AbstractSchemaManager $sm */
        $sm = $this->dbHandler->getConnection()->getSchemaManager();
        foreach ($sm->listTables() as $table) {
            if ($table->getName() == $tableName) {
                return true;
            }
        }

        return false;
    }
37785
public static function checkTableExists(string $tableName): bool
  {
    $query = sprintf('
select 1
from   information_schema.TABLES
where table_schema = database()
and   table_name   = %s', self::$dl->quoteString($tableName));

    return !empty(self::executeSingleton0($query));
  }
1326971
public function getTableWhere($tableName)
    {
        if (!empty($this->tableWheres[$tableName])) {
            return $this->tableWheres[$tableName];
        } elseif ($this->dumpSettings['where']) {
            return $this->dumpSettings['where'];
        }

        return false;
    }