Skip to content

Commit

Permalink
Fix module ID in other tables
Browse files Browse the repository at this point in the history
  • Loading branch information
yurabakhtin committed Sep 24, 2024
1 parent 1ecd7e7 commit fa96a54
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions migrations/m240918_142252_update_module_id.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

use humhub\components\Migration;
use humhub\models\ModuleEnabled;
use humhub\models\Setting;
use humhub\modules\activity\models\Activity;
use humhub\modules\content\models\ContentContainerSetting;

/**
* Class m240918_142252_update_module_id
Expand All @@ -13,10 +16,17 @@ class m240918_142252_update_module_id extends Migration
*/
public function safeUp()
{
$moduleEnabled = ModuleEnabled::findOne(['module_id' => 'custom_pages']);
$oldId = 'custom_pages';
$newId = 'custom-pages';

$moduleEnabled = ModuleEnabled::findOne(['module_id' => $oldId]);
if ($moduleEnabled) {
$moduleEnabled->module_id = 'custom-pages';
$moduleEnabled->module_id = $newId;
$moduleEnabled->save();

Activity::updateAll(['module' => $newId], ['module' => $oldId]);
Setting::updateAll(['module_id' => $newId], ['module_id' => $oldId]);
ContentContainerSetting::updateAll(['module_id' => $newId], ['module_id' => $oldId]);
}
}

Expand Down

0 comments on commit fa96a54

Please sign in to comment.