Skip to content

Commit

Permalink
Fix incorrect index.
Browse files Browse the repository at this point in the history
  • Loading branch information
andris-sevcenko committed Feb 5, 2019
1 parent eb76343 commit 03bbc56
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
### Changed
- The operating system name & version are now shown in the System Report utility. ([#3784](https://github.com/craftcms/cms/issues/3784))

### Fixed
- Fixed a bug where soft delete would not work correctly for assets in some cases.

## 3.1.8 - 2019-02-05

### Changed
Expand Down
2 changes: 1 addition & 1 deletion src/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'id' => 'CraftCMS',
'name' => 'Craft CMS',
'version' => '3.1.8',
'schemaVersion' => '3.1.23',
'schemaVersion' => '3.1.24',
'minVersionRequired' => '2.6.2788',
'basePath' => dirname(__DIR__), // Defines the @app alias
'runtimePath' => '@storage/runtime', // Defines the @runtime alias
Expand Down
2 changes: 1 addition & 1 deletion src/migrations/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ public function createIndexes()
{
$this->createIndex(null, Table::ASSETINDEXDATA, ['sessionId', 'volumeId']);
$this->createIndex(null, Table::ASSETINDEXDATA, ['volumeId'], false);
$this->createIndex(null, Table::ASSETS, ['filename', 'folderId'], true);
$this->createIndex(null, Table::ASSETS, ['filename', 'folderId'], false);
$this->createIndex(null, Table::ASSETS, ['folderId'], false);
$this->createIndex(null, Table::ASSETS, ['volumeId'], false);
$this->createIndex(null, Table::ASSETTRANSFORMINDEX, ['volumeId', 'assetId', 'location'], false);
Expand Down
32 changes: 32 additions & 0 deletions src/migrations/m190205_140000_fix_asset_soft_delete_index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace craft\migrations;

use craft\db\Migration;
use craft\db\Table;
use craft\helpers\MigrationHelper;

/**
* m190205_140000_fix_asset_soft_delete_index migration.
*/
class m190205_140000_fix_asset_soft_delete_index extends Migration
{
/**
* @inheritdoc
*/
public function safeUp()
{
// Unique file names in folder should no longer be enforced by the DB
MigrationHelper::dropIndexIfExists(Table::ASSETS, ['filename', 'folderId'], true, $this);
$this->createIndex(null, Table::ASSETS, ['filename', 'folderId'], false);
}

/**
* @inheritdoc
*/
public function safeDown()
{
echo "m190205_140000_fix_asset_soft_delete_index cannot be reverted.\n";
return false;
}
}

0 comments on commit 03bbc56

Please sign in to comment.