From 03bbc5690506d2c50032adba358aad21c5335cf1 Mon Sep 17 00:00:00 2001 From: andris-sevcenko Date: Tue, 5 Feb 2019 14:46:58 +0200 Subject: [PATCH] Fix incorrect index. --- CHANGELOG-v3.md | 3 ++ src/config/app.php | 2 +- src/migrations/Install.php | 2 +- ...205_140000_fix_asset_soft_delete_index.php | 32 +++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 src/migrations/m190205_140000_fix_asset_soft_delete_index.php diff --git a/CHANGELOG-v3.md b/CHANGELOG-v3.md index 16f19ac20c9..16f10f36e8f 100644 --- a/CHANGELOG-v3.md +++ b/CHANGELOG-v3.md @@ -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 diff --git a/src/config/app.php b/src/config/app.php index 1995946eaed..3dbc1462934 100644 --- a/src/config/app.php +++ b/src/config/app.php @@ -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 diff --git a/src/migrations/Install.php b/src/migrations/Install.php index d9a0946b59e..b16faccf9da 100644 --- a/src/migrations/Install.php +++ b/src/migrations/Install.php @@ -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); diff --git a/src/migrations/m190205_140000_fix_asset_soft_delete_index.php b/src/migrations/m190205_140000_fix_asset_soft_delete_index.php new file mode 100644 index 00000000000..24bb85522f3 --- /dev/null +++ b/src/migrations/m190205_140000_fix_asset_soft_delete_index.php @@ -0,0 +1,32 @@ +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; + } +}