Merge pull request #6416 from nextcloud/make-sure-sqlite-works-without-content

Ask the schema whether the table and column exist
This commit is contained in:
Morris Jobke 2017-09-08 19:09:38 +02:00 committed by GitHub
commit 75c38d5d98
1 changed files with 6 additions and 13 deletions

View File

@ -23,8 +23,6 @@
namespace OC\Repair\Owncloud; namespace OC\Repair\Owncloud;
use Doctrine\DBAL\Exception\InvalidFieldNameException;
use Doctrine\DBAL\Exception\TableNotFoundException;
use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig; use OCP\IConfig;
use OCP\IDBConnection; use OCP\IDBConnection;
@ -86,20 +84,15 @@ class SaveAccountsTableData implements IRepairStep {
* @return bool * @return bool
*/ */
protected function shouldRun() { protected function shouldRun() {
$query = $this->db->getQueryBuilder(); $schema = $this->db->createSchema();
$query->select('*')
->from('accounts')
->where($query->expr()->isNotNull('user_id'))
->setMaxResults(1);
try { $tableName = $this->config->getSystemValue('dbtableprefix', 'oc_') . 'accounts';
$query->execute(); if (!$schema->hasTable($tableName)) {
return true;
} catch (InvalidFieldNameException $e) {
return false;
} catch (TableNotFoundException $e) {
return false; return false;
} }
$table = $schema->getTable($tableName);
return $table->hasColumn('user_id');
} }
/** /**