Advertisement
noC0d3

Subskill Relationship

Sep 9th, 2020
804
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. <?php
  2.  
  3. use Illuminate\Database\Migrations\Migration;
  4. use Illuminate\Database\Schema\Blueprint;
  5. use Illuminate\Support\Facades\Schema;
  6.  
  7. class AddRelationshipToSubSkillsTable extends Migration
  8. {
  9.     /**
  10.      * Run the migrations.
  11.      *
  12.      * @return void
  13.      */
  14.     public function up()
  15.     {
  16.         Schema::table('sub_skills', function (Blueprint $table) {
  17.             $table->foreign('skill_id')->references('id')->on('skills')
  18.                 ->onUpdate('cascade')->onDelete('cascade');
  19.         });
  20.     }
  21.  
  22.     /**
  23.      * Reverse the migrations.
  24.      *
  25.      * @return void
  26.      */
  27.     public function down()
  28.     {
  29.         Schema::table('sub_skills', function (Blueprint $table) {
  30.             $table->dropForeign('sub_skills_skill_id_foreign');
  31.         });
  32.  
  33.         Schema::table('sub_skills', function (Blueprint $table) {
  34.             $table->dropIndex('sub_skills_skill_id_foreign');
  35.         });
  36.     }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement