Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
cc9825c
Allow upgrade from oc 10.5
juliusknorr Sep 25, 2020
5d2988e
Drop fk constraints on locks table
juliusknorr Sep 25, 2020
7f1f896
Fix missing authtoken scope
juliusknorr Sep 25, 2020
934f8a1
Avoid checking for brute force protection capabilities when upgrading
juliusknorr Sep 25, 2020
ab40a7c
Allow major/minor match for owncloud version
juliusknorr Sep 25, 2020
1fef301
Adjust calendars.components to 64 chars
PVince81 Oct 29, 2020
958f796
Adjust further columns
PVince81 Oct 29, 2020
d9bdb5b
Adjust execution duration to 0
PVince81 Oct 29, 2020
a35cba7
Drop oc_dav_job_status table
juliusknorr Nov 20, 2020
3373eff
Drop assignable systemtag column
juliusknorr Nov 20, 2020
1fe7836
Drop attributes on oc_share table
juliusknorr Nov 20, 2020
7c9fcc4
Add missing mount_id index
juliusknorr Nov 27, 2020
8e72e8c
Move authtoken login_name column to varchar(255)
juliusknorr Nov 27, 2020
df44acf
Add missing index on oc_cards and rename if it previously existed
juliusknorr Nov 27, 2020
de369fd
Handle oc_dav_properties migration
juliusknorr Dec 7, 2020
7ce95a4
Readd repair steps that are relevant when migrating from ownCloud
juliusknorr Dec 7, 2020
7c3d3c5
Dump autoloader
juliusknorr Dec 7, 2020
368dac3
Properly migrate from new owncloud avatar location
juliusknorr Dec 9, 2020
0207be4
Change further columns to be nullable with a default of 0
juliusknorr Dec 9, 2020
b84bdb1
Make sure the migrations table schema is always checked
juliusknorr Dec 9, 2020
5dbc94b
Add missing table columns
juliusknorr Sep 25, 2020
be0936d
Bump dav app version
juliusknorr Dec 14, 2020
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
2 changes: 1 addition & 1 deletion apps/dav/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<name>WebDAV</name>
<summary>WebDAV endpoint</summary>
<description>WebDAV endpoint</description>
<version>1.16.1</version>
<version>1.16.2</version>
<licence>agpl</licence>
<author>owncloud.org</author>
<namespace>DAV</namespace>
Expand Down
12 changes: 12 additions & 0 deletions apps/dav/lib/Migration/Version1004Date20170825134824.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,12 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
]);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['principaluri', 'uri'], 'calendars_index');
} else {
$table = $schema->getTable('calendars');
$table->changeColumn('components', [
'notnull' => false,
'length' => 64,
]);
}

if (!$schema->hasTable('calendarchanges')) {
Expand Down Expand Up @@ -335,6 +341,12 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
]);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['principaluri', 'uri'], 'calsub_index');
} else {
$table = $schema->getTable('calendarsubscriptions');
$table->changeColumn('lastmodified', [
'notnull' => false,
'unsigned' => true,
]);
}

if (!$schema->hasTable('schedulingobjects')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
$table->setPrimaryKey(['config_id']);
$table->addIndex(['mount_id'], 'config_mount');
$table->addUniqueIndex(['mount_id', 'key'], 'config_mount_key');
} else {
$table = $schema->getTable('external_config');
$table->changeColumn('value', [
'notnull' => false,
'length' => 4096,
]);
}

if (!$schema->hasTable('external_options')) {
Expand Down
4 changes: 4 additions & 0 deletions core/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ function (GenericEvent $event) use ($container) {
if (!$table->hasIndex('cards_abid')) {
$subject->addHintForMissingSubject($table->getName(), 'cards_abid');
}

if (!$table->hasIndex('cards_abiduri')) {
$subject->addHintForMissingSubject($table->getName(), 'cards_abiduri');
}
}

if ($schema->hasTable('cards_properties')) {
Expand Down
33 changes: 33 additions & 0 deletions core/Command/Db/AddMissingIndices.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,23 @@ private function addCoreIndexes(OutputInterface $output) {
}

$output->writeln('<info>Check indices of the cards table.</info>');
$cardsUpdated = false;
if ($schema->hasTable('cards')) {
$table = $schema->getTable('cards');

if ($table->hasIndex('addressbookid_uri_index')) {
$output->writeln('<info>Renaming addressbookid_uri_index index to to the cards table, this can take some time...</info>');

foreach ($table->getIndexes() as $index) {
if ($index->getColumns() === ['addressbookid', 'uri']) {
$table->renameIndex('addressbookid_uri_index', 'cards_abiduri');
}
}

$this->connection->migrateToSchema($schema->getWrappedSchema());
$cardsUpdated = true;
}

if (!$table->hasIndex('cards_abid')) {
$output->writeln('<info>Adding cards_abid index to the cards table, this can take some time...</info>');

Expand All @@ -206,6 +221,24 @@ private function addCoreIndexes(OutputInterface $output) {

$table->addIndex(['addressbookid'], 'cards_abid');
$this->connection->migrateToSchema($schema->getWrappedSchema());
$cardsUpdated = true;
}

if (!$table->hasIndex('cards_abiduri')) {
$output->writeln('<info>Adding cards_abiduri index to the cards table, this can take some time...</info>');

foreach ($table->getIndexes() as $index) {
if ($index->getColumns() === ['addressbookid', 'uri']) {
$table->dropIndex($index->getName());
}
}

$table->addIndex(['addressbookid', 'uri'], 'cards_abiduri');
$this->connection->migrateToSchema($schema->getWrappedSchema());
$cardsUpdated = true;
}

if ($cardsUpdated) {
$updated = true;
$output->writeln('<info>cards table updated successfully.</info>');
}
Expand Down
105 changes: 101 additions & 4 deletions core/Migrations/Version13000Date20170718121200.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,37 @@

use Doctrine\DBAL\Types\Types;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version13000Date20170718121200 extends SimpleMigrationStep {

/** @var IDBConnection */
private $connection;

public function __construct(IDBConnection $connection) {
$this->connection = $connection;
}

public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

if (!$schema->hasTable('properties')) {
return;
}
// in case we have a properties table from oc we drop it since we will only migrate
// the dav_properties values in the postSchemaChange step
$table = $schema->getTable('properties');
if ($table->hasColumn('fileid')) {
$qb = $this->connection->getQueryBuilder();
$qb->delete('properties');
$qb->execute();
}
}


/**
* @param IOutput $output
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
Expand Down Expand Up @@ -122,6 +148,15 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
$table->addIndex(['root_id'], 'mounts_root_index');
$table->addIndex(['mount_id'], 'mounts_mount_id_index');
$table->addUniqueIndex(['user_id', 'root_id'], 'mounts_user_root_index');
} else {
$table = $schema->getTable('mounts');
$table->addColumn('mount_id', Types::BIGINT, [
'notnull' => false,
'length' => 20,
]);
if (!$table->hasIndex('mounts_mount_id_index')) {
$table->addIndex(['mount_id'], 'mounts_mount_id_index');
}
}

if (!$schema->hasTable('mimetypes')) {
Expand Down Expand Up @@ -320,6 +355,27 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
$table->setPrimaryKey(['id']);
$table->addIndex(['userid'], 'property_index');
$table->addIndex(['userid', 'propertypath'], 'properties_path_index');
} else {
$table = $schema->getTable('properties');
if ($table->hasColumn('propertytype')) {
$table->dropColumn('propertytype');
}
if ($table->hasColumn('fileid')) {
$table->dropColumn('fileid');
}
if (!$table->hasColumn('propertypath')) {
$table->addColumn('propertypath', 'string', [
'notnull' => true,
'length' => 255,
]);
}
if (!$table->hasColumn('userid')) {
$table->addColumn('userid', 'string', [
'notnull' => false,
'length' => 64,
'default' => '',
]);
}
}

if (!$schema->hasTable('share')) {
Expand Down Expand Up @@ -415,6 +471,14 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
$table->addIndex(['parent'], 'parent_index');
$table->addIndex(['uid_owner'], 'owner_index');
$table->addIndex(['uid_initiator'], 'initiator_index');
} else {
$table = $schema->getTable('share');
if (!$table->hasColumn('password')) {
$table->addColumn('password', 'string', [
'notnull' => false,
'length' => 255,
]);
}
}

if (!$schema->hasTable('jobs')) {
Expand Down Expand Up @@ -505,25 +569,25 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
'default' => '',
]);
$table->addColumn('type', 'smallint', [
'notnull' => true,
'notnull' => false,
'length' => 2,
'default' => 0,
'unsigned' => true,
]);
$table->addColumn('remember', 'smallint', [
'notnull' => true,
'notnull' => false,
'length' => 1,
'default' => 0,
'unsigned' => true,
]);
$table->addColumn('last_activity', 'integer', [
'notnull' => true,
'notnull' => false,
'length' => 4,
'default' => 0,
'unsigned' => true,
]);
$table->addColumn('last_check', 'integer', [
'notnull' => true,
'notnull' => false,
'length' => 4,
'default' => 0,
'unsigned' => true,
Expand All @@ -534,6 +598,11 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['token'], 'authtoken_token_index');
$table->addIndex(['last_activity'], 'authtoken_last_activity_idx');
} else {
$table = $schema->getTable('authtoken');
$table->addColumn('scope', 'text', [
'notnull' => false,
]);
}

if (!$schema->hasTable('bruteforce_attempts')) {
Expand Down Expand Up @@ -936,4 +1005,32 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
}
return $schema;
}

public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if (!$schema->hasTable('dav_properties')) {
return;
}
$query = $this->connection->getQueryBuilder();
$query->select('*')
->from('dav_properties');

$insert = $this->connection->getQueryBuilder();
$insert->insert('properties')
->setValue('propertypath', $insert->createParameter('propertypath'))
->setValue('propertyname', $insert->createParameter('propertyname'))
->setValue('propertyvalue', $insert->createParameter('propertyvalue'))
->setValue('userid', $insert->createParameter('userid'));

$result = $query->execute();
while ($row = $result->fetch()) {
preg_match('/(calendar)\/([A-z0-9-@_]+)\//', $row['propertypath'], $match);
$insert->setParameter('propertypath', (string) $row['propertypath'])
->setParameter('propertyname', (string) $row['propertyname'])
->setParameter('propertyvalue', (string) $row['propertyvalue'])
->setParameter('userid', (string) ($match[2] ?? ''));
$insert->execute();
}
}
}
13 changes: 11 additions & 2 deletions core/Migrations/Version13000Date20170919121250.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,17 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
$column->setUnsigned(true);
$column = $table->getColumn('type');
$column->setUnsigned(true);
$column = $table->getColumn('remember');
$column->setUnsigned(true);
if ($table->hasColumn('remember')) {
$column = $table->getColumn('remember');
$column->setUnsigned(true);
} else {
$table->addColumn('remember', 'smallint', [
'notnull' => false,
'length' => 1,
'default' => 0,
'unsigned' => true,
]);
}
$column = $table->getColumn('last_activity');
$column->setUnsigned(true);
$column = $table->getColumn('last_check');
Expand Down
65 changes: 65 additions & 0 deletions core/Migrations/Version21000Date20201120141228.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

declare(strict_types=1);

namespace OC\Core\Migrations;

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version21000Date20201120141228 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

if ($schema->hasTable('authtoken')) {
$table = $schema->getTable('authtoken');
$loginNameColumn = $table->getColumn('login_name');
if ($loginNameColumn->getLength() !== 255) {
$loginNameColumn->setLength(255);
}
$table->changeColumn('type', [
'notnull' => false,
]);
$table->changeColumn('remember', [
'notnull' => false,
]);
$table->changeColumn('last_activity', [
'notnull' => false,
]);
$table->changeColumn('last_check', [
'notnull' => false,
]);
}

if ($schema->hasTable('dav_job_status')) {
$schema->dropTable('dav_job_status');
}

if ($schema->hasTable('systemtag')) {
$table = $schema->getTable('systemtag');
if ($table->hasColumn('systemtag')) {
$table->dropColumn('assignable');
}
}

if ($schema->hasTable('share')) {
$table = $schema->getTable('share');
if ($table->hasColumn('attributes')) {
$table->dropColumn('attributes');
}
}

if ($schema->hasTable('jobs')) {
$table = $schema->getTable('jobs');
$table->changeColumn('execution_duration', [
'notnull' => false,
'default' => 0,
]);
}

return $schema;
}
}
7 changes: 7 additions & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@
'OC\\Core\\Migrations\\Version20000Date20201109081918' => $baseDir . '/core/Migrations/Version20000Date20201109081918.php',
'OC\\Core\\Migrations\\Version20000Date20201109081919' => $baseDir . '/core/Migrations/Version20000Date20201109081919.php',
'OC\\Core\\Migrations\\Version20000Date20201111081915' => $baseDir . '/core/Migrations/Version20000Date20201111081915.php',
'OC\\Core\\Migrations\\Version21000Date20201120141228' => $baseDir . '/core/Migrations/Version21000Date20201120141228.php',
'OC\\Core\\Notification\\CoreNotifier' => $baseDir . '/core/Notification/CoreNotifier.php',
'OC\\Core\\Service\\LoginFlowV2Service' => $baseDir . '/core/Service/LoginFlowV2Service.php',
'OC\\DB\\Adapter' => $baseDir . '/lib/private/DB/Adapter.php',
Expand Down Expand Up @@ -1261,8 +1262,14 @@
'OC\\Repair\\NC20\\EncryptionMigration' => $baseDir . '/lib/private/Repair/NC20/EncryptionMigration.php',
'OC\\Repair\\NC20\\ShippedDashboardEnable' => $baseDir . '/lib/private/Repair/NC20/ShippedDashboardEnable.php',
'OC\\Repair\\OldGroupMembershipShares' => $baseDir . '/lib/private/Repair/OldGroupMembershipShares.php',
'OC\\Repair\\Owncloud\\CleanPreviews' => $baseDir . '/lib/private/Repair/Owncloud/CleanPreviews.php',
'OC\\Repair\\Owncloud\\CleanPreviewsBackgroundJob' => $baseDir . '/lib/private/Repair/Owncloud/CleanPreviewsBackgroundJob.php',
'OC\\Repair\\Owncloud\\DropAccountTermsTable' => $baseDir . '/lib/private/Repair/Owncloud/DropAccountTermsTable.php',
'OC\\Repair\\Owncloud\\InstallCoreBundle' => $baseDir . '/lib/private/Repair/Owncloud/InstallCoreBundle.php',
'OC\\Repair\\Owncloud\\MoveAvatars' => $baseDir . '/lib/private/Repair/Owncloud/MoveAvatars.php',
'OC\\Repair\\Owncloud\\MoveAvatarsBackgroundJob' => $baseDir . '/lib/private/Repair/Owncloud/MoveAvatarsBackgroundJob.php',
'OC\\Repair\\Owncloud\\SaveAccountsTableData' => $baseDir . '/lib/private/Repair/Owncloud/SaveAccountsTableData.php',
'OC\\Repair\\Owncloud\\UpdateLanguageCodes' => $baseDir . '/lib/private/Repair/Owncloud/UpdateLanguageCodes.php',
'OC\\Repair\\RemoveLinkShares' => $baseDir . '/lib/private/Repair/RemoveLinkShares.php',
'OC\\Repair\\RepairInvalidShares' => $baseDir . '/lib/private/Repair/RepairInvalidShares.php',
'OC\\Repair\\RepairMimeTypes' => $baseDir . '/lib/private/Repair/RepairMimeTypes.php',
Expand Down
Loading