38 lines
815 B
PHP
38 lines
815 B
PHP
|
<?php
|
||
|
|
||
|
use Illuminate\Database\Migrations\Migration;
|
||
|
use Illuminate\Database\Schema\Blueprint;
|
||
|
|
||
|
class AddForeignKeysToAbPivotProductCatTable extends Migration {
|
||
|
|
||
|
/**
|
||
|
* Run the migrations.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function up()
|
||
|
{
|
||
|
Schema::table('ab_pivot_product_cat', function(Blueprint $table)
|
||
|
{
|
||
|
$table->foreign('product_id', 'fk_p')->references('id')->on('ab_product')->onUpdate('NO ACTION')->onDelete('NO ACTION');
|
||
|
$table->foreign('product_cat_id', 'fk_pc')->references('id')->on('ab_product_cat')->onUpdate('NO ACTION')->onDelete('NO ACTION');
|
||
|
});
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Reverse the migrations.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function down()
|
||
|
{
|
||
|
Schema::table('ab_pivot_product_cat', function(Blueprint $table)
|
||
|
{
|
||
|
$table->dropForeign('fk_p');
|
||
|
$table->dropForeign('fk_pc');
|
||
|
});
|
||
|
}
|
||
|
|
||
|
}
|