From 51f18db8fa4106a9490b325f0129023965df3f45 Mon Sep 17 00:00:00 2001 From: Alexsander Vyshnyvetskyy Date: Sat, 8 Jul 2023 13:23:11 +0300 Subject: [PATCH] Fix FK in migrations --- CHANGELOG.md | 3 +++ Module.php | 4 +-- README.md | 1 + composer.json | 2 +- migrations/m190730_020217_news.php | 39 ++++++++++++++++++++---------- 5 files changed, 33 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 515b602..6aa7553 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ Changelog ========= +## 2.0.1 (2023-07-08) + * Fix FK in migrations + ## 2.0.0 (2023-06-25) * Some fix, update copyrights * Lang attribute for HTML tags and inputs diff --git a/Module.php b/Module.php index f92941c..c032d26 100644 --- a/Module.php +++ b/Module.php @@ -6,7 +6,7 @@ * Yii2 News * * @category Module - * @version 2.0.0 + * @version 2.0.1 * @author Alexsander Vyshnyvetskyy * @link https://github.com/wdmg/yii2-news * @copyright Copyright (c) 2019 - 2023 W.D.M.Group, Ukraine @@ -47,7 +47,7 @@ class Module extends BaseModule /** * @var string the module version */ - private $version = "2.0.0"; + private $version = "2.0.1"; /** * @var integer, priority of initialization diff --git a/README.md b/README.md index 2c10c4c..4b1e5bf 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,7 @@ Use the `Module::dashboardNavItems()` method of the module to generate a navigat ?> # Status and version [ready to use] +* v.2.0.1 - Fix FK in migrations * v.2.0.0 - Some fix, update copyrights * v.1.1.4 - RBAC implementation * v.1.1.3 - URL redirect notify, defaultController property, update dependencies and README.md diff --git a/composer.json b/composer.json index 37ad253..c8b9f00 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ ], "type": "yii2-extension", "license": "MIT", - "version": "2.0.0", + "version": "2.0.1", "homepage": "https://github.com/wdmg/yii2-news", "support": { "source": "https://github.com/wdmg/yii2-news", diff --git a/migrations/m190730_020217_news.php b/migrations/m190730_020217_news.php index 0f8061f..c2948ed 100644 --- a/migrations/m190730_020217_news.php +++ b/migrations/m190730_020217_news.php @@ -56,15 +56,24 @@ public function safeUp() // If exist module `Users` set foreign key `created_by`, `updated_by` to `users.id` if (class_exists('\wdmg\users\models\Users')) { $userTable = \wdmg\users\models\Users::tableName(); - $this->addForeignKey( - 'fk_news_to_users', - '{{%news}}', - 'created_by, updated_by', - $userTable, - 'id', - 'NO ACTION', - 'CASCADE' - ); + $this->addForeignKey( + 'fk_news_to_users1', + '{{%news}}', + 'created_by', + $userTable, + 'id', + 'NO ACTION', + 'CASCADE' + ); + $this->addForeignKey( + 'fk_news_to_users2', + '{{%news}}', + 'updated_by', + $userTable, + 'id', + 'NO ACTION', + 'CASCADE' + ); } } @@ -82,10 +91,14 @@ public function safeDown() if(class_exists('\wdmg\users\models\Users') && isset(Yii::$app->modules['users'])) { $userTable = \wdmg\users\models\Users::tableName(); if (!(Yii::$app->db->getTableSchema($userTable, true) === null)) { - $this->dropForeignKey( - 'fk_news_to_users', - '{{%news}}' - ); + $this->dropForeignKey( + 'fk_news_to_users1', + '{{%news}}' + ); + $this->dropForeignKey( + 'fk_news_to_users2', + '{{%news}}' + ); } }