From daff39fad9bad2b88749b1823f027257c57d9095 Mon Sep 17 00:00:00 2001 From: VicDeo Date: Tue, 4 Sep 2018 18:04:49 +0300 Subject: [PATCH] Alter oc_jobs before enabing market app --- core/Migrations/Version20170101010030.php | 51 +++++++++++++++++++++++ core/Migrations/Version20170213215145.php | 13 +++--- lib/private/Repair/Apps.php | 5 +++ 3 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 core/Migrations/Version20170101010030.php diff --git a/core/Migrations/Version20170101010030.php b/core/Migrations/Version20170101010030.php new file mode 100644 index 000000000000..0c4ac86f2cf3 --- /dev/null +++ b/core/Migrations/Version20170101010030.php @@ -0,0 +1,51 @@ +hasTable("${prefix}jobs")) { + $jobsTable = $schema->getTable("${prefix}jobs"); + + if (!$jobsTable->hasColumn('last_checked')) { + $jobsTable->addColumn( + 'last_checked', + Type::INTEGER, + [ + 'default' => 0, + 'notnull' => false + ] + ); + } + + if (!$jobsTable->hasColumn('reserved_at')) { + $jobsTable->addColumn( + 'reserved_at', + Type::INTEGER, + [ + 'default' => 0, + 'notnull' => false + ] + ); + } + + if (!$jobsTable->hasColumn('execution_duration')) { + $jobsTable->addColumn('execution_duration', Type::INTEGER, [ + 'notnull' => true, + 'length' => 5, + 'default' => -1, + ]); + } + } + } +} diff --git a/core/Migrations/Version20170213215145.php b/core/Migrations/Version20170213215145.php index ea967f0a3b99..4e534e151be5 100644 --- a/core/Migrations/Version20170213215145.php +++ b/core/Migrations/Version20170213215145.php @@ -13,12 +13,13 @@ public function changeSchema(Schema $schema, array $options) { $prefix = $options['tablePrefix']; if ($schema->hasTable("${prefix}jobs")) { $table = $schema->getTable("${prefix}jobs"); - - $table->addColumn('execution_duration', 'integer', [ - 'notnull' => true, - 'length' => 5, - 'default' => -1, - ]); + if (!$table->hasColumn('execution_duration')) { + $table->addColumn('execution_duration', 'integer', [ + 'notnull' => true, + 'length' => 5, + 'default' => -1, + ]); + } } } } diff --git a/lib/private/Repair/Apps.php b/lib/private/Repair/Apps.php index f4dd8b6c6755..dadad5c634e8 100644 --- a/lib/private/Repair/Apps.php +++ b/lib/private/Repair/Apps.php @@ -21,6 +21,7 @@ namespace OC\Repair; +use OC\DB\MigrationService; use OC\RepairException; use OC_App; use OCP\App\AppAlreadyInstalledException; @@ -326,6 +327,10 @@ private function fixMarketAppState(IOutput $output) { // Then we need to enable the market app to support app updates / downloads during upgrade $output->info('Enabling market app to assist with update'); try { + // Prepare oc_jobs for older ownCloud version fixes https://github.com/owncloud/update-testing/issues/5 + $ms = new MigrationService('core', \OC::$server->getDatabaseConnection(), $output); + $ms->executeStep('20170101010030'); + $this->appManager->enableApp('market'); return true; } catch (\Exception $ex) {