Skip to content

Commit

Permalink
[Improvement]: Add versionCount index to element and versions table (
Browse files Browse the repository at this point in the history
  • Loading branch information
kingjia90 authored Oct 22, 2024
1 parent 02298c3 commit fec1c09
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 4 deletions.
56 changes: 56 additions & 0 deletions bundles/CoreBundle/src/Migrations/Version20241021111028.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

declare(strict_types=1);

/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\CoreBundle\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20241021111028 extends AbstractMigration
{
protected array $tables = [
'assets',
'documents',
'objects',
'versions',
];

public function getDescription(): string
{
return 'Add versionCount index to elements and versions table';
}

public function up(Schema $schema): void
{
foreach ($this->tables as $table) {
$dbTable = $schema->getTable($table);
if (!$dbTable->hasIndex('versionCount')) {
$dbTable->addIndex(['versionCount'], 'versionCount');
}
}
}

public function down(Schema $schema): void
{
foreach ($this->tables as $table) {
$dbTable = $schema->getTable($table);
if ($dbTable->hasIndex('versionCount')) {
$dbTable->dropIndex('versionCount');
}
}
}
}
12 changes: 8 additions & 4 deletions bundles/InstallBundle/dump/install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ CREATE TABLE `assets` (
UNIQUE KEY `fullpath` (`path`,`filename`),
KEY `parentId` (`parentId`),
KEY `filename` (`filename`),
KEY `modificationDate` (`modificationDate`)
KEY `modificationDate` (`modificationDate`),
KEY `versionCount` (`versionCount`)
) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

DROP TABLE IF EXISTS `assets_metadata`;
Expand Down Expand Up @@ -90,7 +91,8 @@ CREATE TABLE `documents` (
KEY `parentId` (`parentId`),
KEY `key` (`key`),
KEY `published` (`published`),
KEY `modificationDate` (`modificationDate`)
KEY `modificationDate` (`modificationDate`),
KEY `versionCount` (`versionCount`)
) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

DROP TABLE IF EXISTS `documents_editables`;
Expand Down Expand Up @@ -290,7 +292,8 @@ CREATE TABLE `objects` (
KEY `parentId` (`parentId`),
KEY `type_path_classId` (`type`, `path`, `classId`),
KEY `modificationDate` (`modificationDate`),
KEY `classId` (`classId`)
KEY `classId` (`classId`),
KEY `versionCount` (`versionCount`)
) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

DROP TABLE IF EXISTS `properties`;
Expand Down Expand Up @@ -588,7 +591,8 @@ CREATE TABLE `versions` (
KEY `date` (`date`),
KEY `binaryFileHash` (`binaryFileHash`),
KEY `autoSave` (`autoSave`),
KEY `stackTrace` (`stackTrace`(1))
KEY `stackTrace` (`stackTrace`(1)),
KEY `versionCount` (`versionCount`)
) DEFAULT CHARSET=utf8mb4;

DROP TABLE IF EXISTS `website_settings`;
Expand Down
5 changes: 5 additions & 0 deletions doc/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
### [Events]
- `context` property of `ResolveUploadTargetEvent` is deprecated. Use `setArgument()` method instead.

## Pimcore 11.5.0
### General
#### [Database]
- Added an index on `versionCount` columns

## Pimcore 11.4.0
### General
#### [Logging]
Expand Down

0 comments on commit fec1c09

Please sign in to comment.