Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Stable10] Fix update cases from 9.0.9 and below #32573

Merged
merged 1 commit into from
Sep 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
]);
}
}
}
}
56 changes: 55 additions & 1 deletion lib/private/Repair/Apps.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @author Victor Dubiniuk <dubiniuk@aheadworks.com>
* @author Viktar Dubiniuk <dubiniuk@owncloud.com>
*
* @copyright Copyright (c) 2018, ownCloud GmbH
* @license AGPL-3.0
Expand All @@ -21,6 +21,8 @@

namespace OC\Repair;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
use OC\RepairException;
use OC_App;
use OCP\App\AppAlreadyInstalledException;
Expand Down Expand Up @@ -326,11 +328,63 @@ 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
$connection = \OC::$server->getDatabaseConnection();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add a OC version check, just to be safe ? this is only when upgrading pre-OC where oc_jobs had the old schema and no oc_migrations existed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

market app is enabled only if an initial oc version < 10.0.0 and app store was not explicitely disabled before

$toSchema = $connection->createSchema();
$this->changeSchema($toSchema, ['tablePrefix' => $connection->getPrefix()]);
$connection->migrateToSchema($toSchema);

$this->appManager->enableApp('market');
return true;
} catch (\Exception $ex) {
$output->warning($ex->getMessage());
return false;
}
}

/**
* DB update for oc_jobs table
* it is intentionally duplicates 20170213215145 and a part of 20170101215145
* to allow seamless market app installation
*
* @param Schema $schema
* @param array $options
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
private 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,
]);
}
}
}
}