api
This commit is contained in:
@ -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;
|
||||
}
|
||||
*/
|
||||
}
|
Reference in New Issue
Block a user