<?php

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

class CreateStudentsTable extends Migration
{

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('students', function (Blueprint $table) {

			$table->increments('id');
			$table->char('number', 9);
			$table->string('name', 100);
			$table->char('gender', 4);
			$table->char('school_code', 2)->nullable();
			$table->char('conc_code', 4)->nullable();
			$table->char("degree", 3);
			$table->char('level', 3);
			$table->char("year", 3);
			$table->string('email', 40)->default('no.email.olas@upr.edu');
			$table->integer('program_id')->unsigned()->nullable();
			$table->char("modality", 1);

			$table->timestamps();
		});

		Schema::table('students', function (Blueprint $table) {
			$table->foreign('program_id')->references('id')->on('programs')->onDelete('cascade')->onUpdate('cascade');
		});
	}


	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('students');
	}
}
