From b45be5041d93e613983ca0e7b8ebf46b098224c1 Mon Sep 17 00:00:00 2001 From: Semenov Date: Tue, 7 Apr 2020 10:59:11 +0300 Subject: [PATCH] dev --- ...110601__alter_table__cms_search_phrase.php | 43 +++++++++++++++++++ src/models/CmsSearchPhrase.php | 12 +++--- 2 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 src/migrations/m200406_110601__alter_table__cms_search_phrase.php diff --git a/src/migrations/m200406_110601__alter_table__cms_search_phrase.php b/src/migrations/m200406_110601__alter_table__cms_search_phrase.php new file mode 100644 index 0000000..c1e0a6a --- /dev/null +++ b/src/migrations/m200406_110601__alter_table__cms_search_phrase.php @@ -0,0 +1,43 @@ + + * @link http://skeeks.com/ + * @copyright 2010 SkeekS (СкикС) + * @date 28.08.2015 + */ + +use yii\db\Migration; + +class m200406_110601__alter_table__cms_search_phrase extends Migration +{ + public function safeUp() + { + $tableName = "cms_search_phrase"; + + $this->addColumn($tableName, "cms_site_id", $this->integer()); + + $result = \Yii::$app->db->createCommand(<<execute(); + + $this->dropForeignKey("cms_search_phrase_site_code_fk", $tableName); + $this->dropColumn($tableName, "site_code"); + + + $this->addForeignKey( + "{$tableName}__cms_site_id", $tableName, + 'cms_site_id', '{{%cms_site}}', 'id', 'CASCADE', 'CASCADE' + ); + } + + public function safeDown() + { + echo "m200406_080601__alter_table__shop_order cannot be reverted.\n"; + return false; + } +} \ No newline at end of file diff --git a/src/models/CmsSearchPhrase.php b/src/models/CmsSearchPhrase.php index 798be3a..9f67c20 100644 --- a/src/models/CmsSearchPhrase.php +++ b/src/models/CmsSearchPhrase.php @@ -26,12 +26,12 @@ * @property integer $result_count * @property integer $pages * @property string $ip - * @property string $site_code * @property string $data_server * @property string $data_session * @property string $data_cookie * @property string $data_request * @property string $session_id + * @property integer|null $cms_site_id * * @property CmsSite $site */ @@ -71,7 +71,7 @@ public function rules() [['data_server', 'data_session', 'data_cookie', 'data_request'], 'string'], [['phrase'], 'string', 'max' => 255], [['ip'], 'string', 'max' => 32], - [['site_code'], 'string', 'max' => 15], + [['cms_site_id'], 'integer'], ['data_request', 'default', 'value' => $_REQUEST], ['data_server', 'default', 'value' => $_SERVER], @@ -94,11 +94,11 @@ public function rules() ], [ - ['site_code'], + ['cms_site_id'], 'default', 'value' => function (self $model, $attribute) { if (\Yii::$app->cms->site) { - return \Yii::$app->cms->site->code; + return \Yii::$app->cms->site->id; } return null; @@ -125,7 +125,7 @@ public function attributeLabels() 'result_count' => Yii::t('skeeks/search', 'Documents Found'), 'pages' => Yii::t('skeeks/search', 'Pages Count'), 'ip' => Yii::t('skeeks/search', 'Ip'), - 'site_code' => Yii::t('skeeks/search', 'Site'), + 'cms_site_id' => Yii::t('skeeks/search', 'Site'), 'data_server' => Yii::t('skeeks/search', 'Data Server'), 'data_session' => Yii::t('skeeks/search', 'Data Session'), 'data_cookie' => Yii::t('skeeks/search', 'Data Cookie'), @@ -138,6 +138,6 @@ public function attributeLabels() */ public function getSite() { - return $this->hasOne(CmsSite::className(), ['code' => 'site_code']); + return $this->hasOne(CmsSite::className(), ['id' => 'cms_site_id']); } } \ No newline at end of file