aboutsummaryrefslogtreecommitdiffstats
path: root/core/Migrations
diff options
context:
space:
mode:
Diffstat (limited to 'core/Migrations')
-rw-r--r--core/Migrations/Version13000Date20170705121758.php1
-rw-r--r--core/Migrations/Version13000Date20170718121200.php2
-rw-r--r--core/Migrations/Version13000Date20170814074715.php1
-rw-r--r--core/Migrations/Version13000Date20170919121250.php1
-rw-r--r--core/Migrations/Version13000Date20170926101637.php1
-rw-r--r--core/Migrations/Version14000Date20180129121024.php1
-rw-r--r--core/Migrations/Version14000Date20180516101403.php1
-rw-r--r--core/Migrations/Version14000Date20180626223656.php1
-rw-r--r--core/Migrations/Version14000Date20180712153140.php1
-rw-r--r--core/Migrations/Version23000Date20210721100600.php2
-rw-r--r--core/Migrations/Version25000Date20220515204012.php1
-rw-r--r--core/Migrations/Version29000Date20240131122720.php4
-rw-r--r--core/Migrations/Version30000Date20240906095113.php2
-rw-r--r--core/Migrations/Version32000Date20250620081925.php16
-rw-r--r--core/Migrations/Version32000Date20250731062008.php106
15 files changed, 137 insertions, 4 deletions
diff --git a/core/Migrations/Version13000Date20170705121758.php b/core/Migrations/Version13000Date20170705121758.php
index 7233cc0302e..17262cf0743 100644
--- a/core/Migrations/Version13000Date20170705121758.php
+++ b/core/Migrations/Version13000Date20170705121758.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/core/Migrations/Version13000Date20170718121200.php b/core/Migrations/Version13000Date20170718121200.php
index 1adbf2f0ea2..35c2d1730bc 100644
--- a/core/Migrations/Version13000Date20170718121200.php
+++ b/core/Migrations/Version13000Date20170718121200.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -657,6 +658,7 @@ class Version13000Date20170718121200 extends SimpleMigrationStep {
$table->addIndex(['uid'], 'uid_index');
$table->addIndex(['type'], 'type_index');
$table->addIndex(['category'], 'category_index');
+ $table->addUniqueIndex(['uid', 'type', 'category'], 'unique_category_per_user');
}
if (!$schema->hasTable('vcategory_to_object')) {
diff --git a/core/Migrations/Version13000Date20170814074715.php b/core/Migrations/Version13000Date20170814074715.php
index 73de1af0e0a..6e7ca19fc3c 100644
--- a/core/Migrations/Version13000Date20170814074715.php
+++ b/core/Migrations/Version13000Date20170814074715.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/core/Migrations/Version13000Date20170919121250.php b/core/Migrations/Version13000Date20170919121250.php
index ae6eff99bcd..b3e9541d605 100644
--- a/core/Migrations/Version13000Date20170919121250.php
+++ b/core/Migrations/Version13000Date20170919121250.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/core/Migrations/Version13000Date20170926101637.php b/core/Migrations/Version13000Date20170926101637.php
index 42bbf74fb74..aca772de313 100644
--- a/core/Migrations/Version13000Date20170926101637.php
+++ b/core/Migrations/Version13000Date20170926101637.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/core/Migrations/Version14000Date20180129121024.php b/core/Migrations/Version14000Date20180129121024.php
index 6da5f2602e8..c16d95ed71b 100644
--- a/core/Migrations/Version14000Date20180129121024.php
+++ b/core/Migrations/Version14000Date20180129121024.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/core/Migrations/Version14000Date20180516101403.php b/core/Migrations/Version14000Date20180516101403.php
index c024b1b93ab..a71673a9674 100644
--- a/core/Migrations/Version14000Date20180516101403.php
+++ b/core/Migrations/Version14000Date20180516101403.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/core/Migrations/Version14000Date20180626223656.php b/core/Migrations/Version14000Date20180626223656.php
index 3a08fb45c20..7d4dea585f6 100644
--- a/core/Migrations/Version14000Date20180626223656.php
+++ b/core/Migrations/Version14000Date20180626223656.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/core/Migrations/Version14000Date20180712153140.php b/core/Migrations/Version14000Date20180712153140.php
index 4d27a60bbb4..b1a295ea2f6 100644
--- a/core/Migrations/Version14000Date20180712153140.php
+++ b/core/Migrations/Version14000Date20180712153140.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/core/Migrations/Version23000Date20210721100600.php b/core/Migrations/Version23000Date20210721100600.php
index 72437337326..a611c0c4b36 100644
--- a/core/Migrations/Version23000Date20210721100600.php
+++ b/core/Migrations/Version23000Date20210721100600.php
@@ -36,7 +36,7 @@ class Version23000Date20210721100600 extends SimpleMigrationStep {
'notnull' => true,
'length' => 200,
]);
-
+
$table->setPrimaryKey(['id']);
$table->addIndex(['group_id'], 'admindel_groupid_idx');
return $schema;
diff --git a/core/Migrations/Version25000Date20220515204012.php b/core/Migrations/Version25000Date20220515204012.php
index 2ec96bc5175..7f7c6b6cee2 100644
--- a/core/Migrations/Version25000Date20220515204012.php
+++ b/core/Migrations/Version25000Date20220515204012.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2019 ownCloud GmbH
* SPDX-License-Identifier: AGPL-3.0-only
diff --git a/core/Migrations/Version29000Date20240131122720.php b/core/Migrations/Version29000Date20240131122720.php
index 14f02331587..abd5e73165a 100644
--- a/core/Migrations/Version29000Date20240131122720.php
+++ b/core/Migrations/Version29000Date20240131122720.php
@@ -29,8 +29,8 @@ class Version29000Date20240131122720 extends SimpleMigrationStep {
$tableProperties = $schema->getTable('properties');
- if ($tableProperties->hasIndex('property_index') &&
- $tableProperties->hasIndex('properties_path_index')) {
+ if ($tableProperties->hasIndex('property_index')
+ && $tableProperties->hasIndex('properties_path_index')) {
$tableProperties->dropIndex('property_index');
}
diff --git a/core/Migrations/Version30000Date20240906095113.php b/core/Migrations/Version30000Date20240906095113.php
index bab03241db4..7c3efe41bc3 100644
--- a/core/Migrations/Version30000Date20240906095113.php
+++ b/core/Migrations/Version30000Date20240906095113.php
@@ -31,7 +31,7 @@ class Version30000Date20240906095113 extends SimpleMigrationStep {
if ($schema->hasTable('taskprocessing_tasks')) {
$table = $schema->getTable('taskprocessing_tasks');
$column = $table->getColumn('error_message');
-
+
if ($column->getLength() < 4000) {
$column->setLength(4000);
}
diff --git a/core/Migrations/Version32000Date20250620081925.php b/core/Migrations/Version32000Date20250620081925.php
new file mode 100644
index 00000000000..13e1ac0f87d
--- /dev/null
+++ b/core/Migrations/Version32000Date20250620081925.php
@@ -0,0 +1,16 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OC\Core\Migrations;
+
+/**
+ * Run the old migration Version24000Date20211210141942 again.
+ */
+class Version32000Date20250620081925 extends Version24000Date20211210141942 {
+}
diff --git a/core/Migrations/Version32000Date20250731062008.php b/core/Migrations/Version32000Date20250731062008.php
new file mode 100644
index 00000000000..bf15e4a0b22
--- /dev/null
+++ b/core/Migrations/Version32000Date20250731062008.php
@@ -0,0 +1,106 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OC\Core\Migrations;
+
+use Closure;
+use OCP\DB\ISchemaWrapper;
+use OCP\IDBConnection;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+use Override;
+
+/**
+ * Make sure vcategory entries are unique per user and type
+ * This migration will clean up existing duplicates
+ * and add a unique constraint to prevent future duplicates.
+ */
+class Version32000Date20250731062008 extends SimpleMigrationStep {
+ public function __construct(
+ private IDBConnection $connection,
+ ) {
+ }
+
+ /**
+ * @param IOutput $output
+ * @param Closure(): ISchemaWrapper $schemaClosure
+ * @param array $options
+ */
+ #[Override]
+ public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
+ // Clean up duplicate categories before adding unique constraint
+ $this->cleanupDuplicateCategories($output);
+ }
+
+ /**
+ * Clean up duplicate categories
+ */
+ private function cleanupDuplicateCategories(IOutput $output) {
+ $output->info('Starting cleanup of duplicate vcategory records...');
+
+ // Find all categories, ordered to identify duplicates
+ $qb = $this->connection->getQueryBuilder();
+ $qb->select('id', 'uid', 'type', 'category')
+ ->from('vcategory')
+ ->orderBy('uid')
+ ->addOrderBy('type')
+ ->addOrderBy('category')
+ ->addOrderBy('id');
+
+ $result = $qb->executeQuery();
+
+ $seen = [];
+ $duplicateCount = 0;
+
+ while ($category = $result->fetch()) {
+ $key = $category['uid'] . '|' . $category['type'] . '|' . $category['category'];
+ $categoryId = (int)$category['id'];
+
+ if (!isset($seen[$key])) {
+ // First occurrence - keep this one
+ $seen[$key] = $categoryId;
+ continue;
+ }
+
+ // Duplicate found
+ $keepId = $seen[$key];
+ $duplicateCount++;
+
+ $output->info("Found duplicate: keeping ID $keepId, removing ID $categoryId");
+
+ // Update object references
+ $updateQb = $this->connection->getQueryBuilder();
+ $updateQb->update('vcategory_to_object')
+ ->set('categoryid', $updateQb->createNamedParameter($keepId))
+ ->where($updateQb->expr()->eq('categoryid', $updateQb->createNamedParameter($categoryId)));
+
+ $affectedRows = $updateQb->executeStatement();
+ if ($affectedRows > 0) {
+ $output->info(" - Updated $affectedRows object references from category $categoryId to $keepId");
+ }
+
+ // Remove duplicate category record
+ $deleteQb = $this->connection->getQueryBuilder();
+ $deleteQb->delete('vcategory')
+ ->where($deleteQb->expr()->eq('id', $deleteQb->createNamedParameter($categoryId)));
+
+ $deleteQb->executeStatement();
+ $output->info(" - Deleted duplicate category record ID $categoryId");
+
+ }
+
+ $result->closeCursor();
+
+ if ($duplicateCount === 0) {
+ $output->info('No duplicate categories found');
+ } else {
+ $output->info("Duplicate cleanup completed - processed $duplicateCount duplicates");
+ }
+ }
+}