-
Notifications
You must be signed in to change notification settings - Fork 5
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
2ae54ef
commit f028c75
Showing
4 changed files
with
128 additions
and
5 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/migrations/m240704_163220_create_table__shop_product_model.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,37 @@ | ||
<?php | ||
/** | ||
* @author Semenov Alexander <[email protected]> | ||
* @link http://skeeks.com/ | ||
* @copyright 2010 SkeekS (СкикС) | ||
* @date 28.08.2015 | ||
*/ | ||
use yii\db\Migration; | ||
|
||
class m240704_163220_create_table__shop_product_model extends Migration | ||
{ | ||
public function safeUp() | ||
{ | ||
$tableName = 'shop_product_model'; | ||
$tableExist = $this->db->getTableSchema($tableName, true); | ||
if ($tableExist) { | ||
return true; | ||
} | ||
|
||
$tableOptions = null; | ||
if ($this->db->driverName === 'mysql') { | ||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB'; | ||
} | ||
|
||
$this->createTable($tableName, [ | ||
'id' => $this->primaryKey(), | ||
|
||
'created_at' => $this->integer(), | ||
|
||
], $tableOptions); | ||
|
||
$this->createIndex($tableName.'__created_at', $tableName, 'created_at'); | ||
} | ||
|
||
public function safeDown() | ||
{} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/migrations/m240704_163221_alter_table__shop_product.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,32 @@ | ||
<?php | ||
/** | ||
* @author Semenov Alexander <[email protected]> | ||
* @link http://skeeks.com/ | ||
* @copyright 2010 SkeekS (СкикС) | ||
* @date 28.08.2015 | ||
*/ | ||
|
||
use yii\db\Migration; | ||
|
||
class m240704_163221_alter_table__shop_product extends Migration | ||
{ | ||
public function safeUp() | ||
{ | ||
$tableName = 'shop_product'; | ||
|
||
$this->addColumn($tableName, "shop_product_model_id", $this->integer()->null()->comment("Связь с моделью")); | ||
|
||
$this->createIndex("{$tableName}__shop_product_model_id", $tableName, "shop_product_model_id"); | ||
|
||
$this->addForeignKey( | ||
"{$tableName}__shop_product_model_id", $tableName, | ||
'shop_product_model_id', '{{%shop_product_model}}', 'id', 'SET NULL', 'SET NULL' | ||
); | ||
} | ||
|
||
public function safeDown() | ||
{ | ||
echo "m240411_142301__alter_table__shop_store 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
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,41 @@ | ||
<?php | ||
/** | ||
* @author Semenov Alexander <[email protected]> | ||
* @link http://skeeks.com/ | ||
* @copyright 2010 SkeekS (СкикС) | ||
* @date 14.09.2015 | ||
*/ | ||
|
||
namespace skeeks\cms\shop\models; | ||
|
||
use skeeks\cms\base\ActiveRecord; | ||
use skeeks\modules\cms\money\models\Currency; | ||
|
||
/** | ||
* This is the model class for table "{{%shop_product}}". | ||
* | ||
* @property integer $id | ||
* @property integer $created_at | ||
* | ||
* @property ShopProduct[] $shopProducts | ||
*/ | ||
class ShopProductModel extends ActiveRecord | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public static function tableName() | ||
{ | ||
return '{{%shop_product_model}}'; | ||
} | ||
|
||
|
||
/** | ||
* @return \yii\db\ActiveQuery | ||
*/ | ||
public function getShopProducts() | ||
{ | ||
return $this->hasMany(ShopProduct::class, ['shop_product_model_id' => 'id']); | ||
} | ||
|
||
} |