-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec3f71b
commit b45be50
Showing
2 changed files
with
49 additions
and
6 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/migrations/m200406_110601__alter_table__cms_search_phrase.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* @author Semenov Alexander <[email protected]> | ||
* @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(<<<SQL | ||
UPDATE | ||
`cms_search_phrase` as spts | ||
LEFT JOIN cms_site site on site.code = spts.site_code | ||
SET | ||
spts.`cms_site_id` = site.id | ||
SQL | ||
)->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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters