Skip to content

Commit

Permalink
Alter oc_jobs before enabing market app
Browse files Browse the repository at this point in the history
  • Loading branch information
VicDeo committed Sep 4, 2018
1 parent 172f3cd commit daff39f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 6 deletions.
51 changes: 51 additions & 0 deletions core/Migrations/Version20170101010030.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace OC\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
use OCP\Migration\ISchemaMigration;

/**
* DB update for oc_jobs table
* it is intentionally duplicates 20170213215145 and a part of 20170101215145
* to allow seamless market app installation
*/
class Version20170101010030 implements ISchemaMigration {
public function changeSchema(Schema $schema, array $options) {
$prefix = $options['tablePrefix'];
if ($schema->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,
]);
}
}
}
}
13 changes: 7 additions & 6 deletions core/Migrations/Version20170213215145.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
}
}
}
}
5 changes: 5 additions & 0 deletions lib/private/Repair/Apps.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

namespace OC\Repair;

use OC\DB\MigrationService;
use OC\RepairException;
use OC_App;
use OCP\App\AppAlreadyInstalledException;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit daff39f

Please sign in to comment.