<?php

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

class CreateTableNoteItem extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('Note_Item', function(Blueprint $table) {
			$table->increments('id_Note_Item');
			$table->integer('note')->default(0);

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

            $table->integer('id_Note_Station')->unsigned();
            $table->foreign('id_Note_Station')->references('id_Note_Station')->on('Note_Station')
                        ->onDelete('cascade')
                        ->onUpdate('cascade');
		});
    }

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