photo/database/migrations/2016_06_03_055605_add_foreign_keys_to_photo_tag_table.php
2016-06-22 16:53:48 +10:00

38 lines
769 B
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddForeignKeysToPhotoTagTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('photo_tag', function(Blueprint $table)
{
$table->foreign('photo_id', 'fk_pt_p')->references('id')->on('photo')->onUpdate('NO ACTION')->onDelete('NO ACTION');
$table->foreign('tag_id', 'fk_pt_t')->references('id')->on('tags')->onUpdate('NO ACTION')->onDelete('NO ACTION');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('photo_tag', function(Blueprint $table)
{
$table->dropForeign('fk_pt_p');
$table->dropForeign('fk_pt_t');
});
}
}