<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTableService extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('Service', function(Blueprint $table) {
			$table->increments('id_Service');
			$table->string('nom', 100);


            $table->integer('id_Stage')->unsigned();
            $table->foreign('id_Stage')->references('id_Stage')->on('Stage')
                        ->onDelete('cascade')
                        ->onUpdate('cascade');
            
            $table->integer('id_Specialite')->unsigned();
            $table->foreign('id_Specialite')->references('id_Specialite')->on('Specialite')
                        ->onDelete('cascade')
                        ->onUpdate('cascade');

            $table->integer('id_Hopital')->unsigned();
            $table->foreign('id_Hopital')->references('id_Hopital')->on('Hopital')
                        ->onDelete('cascade')
                        ->onUpdate('cascade');


		});
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('Service', function(Blueprint $table) {
            $table->dropForeign('Service_id_Stage_foreign');
            $table->dropForeign('Service_id_Specialite_foreign');
            $table->dropForeign('Service_id_Hopital_foreign');
        });
        Schema::drop('Service');
    }
}
