Hot fix for -- Rebuild group default Space Mapping #4586 (#4732)

#4586 corrected migration - delete foreign key.
This commit is contained in:
Alexander Suvorov 2020-12-29 20:11:57 +03:00 committed by GitHub
parent c01dda1896
commit 4ab82a8aa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
<?php
use yii\db\Migration;
use humhub\components\Migration;
/**
* Class m201025_095247_spaces_of_users_group
@ -37,8 +38,12 @@ class m201025_095247_spaces_of_users_group extends Migration
]);
}
$this->dropColumn('group', 'space_id');
try {
$this->dropForeignKey('fk_group-space_id', 'group');
} catch (\Exception $e) {
}
$this->safeDropColumn('group', 'space_id');
}
/**
@ -46,6 +51,8 @@ class m201025_095247_spaces_of_users_group extends Migration
*/
public function safeDown()
{
$this->addColumn('group', 'space_id', $this->integer(10)->defaultValue(null));
$this->addForeignKey('fk_group-space_id', 'group', 'space_id', 'space', 'id', 'CASCADE', 'CASCADE');
$this->dropTable('group_space');
}