This commit is contained in:
2024-05-24 15:27:07 +03:00
parent 17df2ce6a9
commit fc1da2c238
643 changed files with 110185 additions and 231 deletions

View File

@ -0,0 +1,62 @@
<?php
use yii\db\Migration;
/**
* Class m240507_141733_add_category_id_column_at_product_table
*/
class m240507_141733_add_category_id_column_at_product_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('product', 'product_category_id', $this->integer(11)->defaultValue(0)->notNull());
$this->createIndex('idx-product-product_category_id', 'product', 'product_category_id');
$this->addForeignKey(
'fk-product-product_category_id',
'product',
'product_category_id',
'product_category',
'id',
'CASCADE'
);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey(
'fk-product-product_category_id',
'product'
);
// drops index for column `author_id`
$this->dropIndex(
'idx-product-product_category_id',
'product'
);
$this->dropColumn('product', 'product_category_id');
}
/*
// Use up()/down() to run migration code without a transaction.
public function up()
{
}
public function down()
{
echo "m240507_141733_add_category_id_column_at_product_table cannot be reverted.\n";
return false;
}
*/
}