<?php

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

class CreateAppointmentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('appointments', function (Blueprint $table) {
            $table->string('id')->primary();
            $table->unsignedBigInteger('users_id');
            $table->string('patients_id');
            $table->string('code')->unique('appointments_code_unique');
            $table->timestamp('date');
            $table->string('especiality', 5);
            $table->bigInteger('active')->default(1);
            $table->bigInteger('deleted')->default(0);
            $table->string('summary')->nullable();
            $table->timestamp('created_at')->useCurrent();
            $table->timestamp('updated_at')->nullable();
            
            $table->foreign('especiality', 'FK_3b5aae2db5674f31fd052f5bf18')->references('id')->on('especiality');
            $table->foreign('users_id', 'FK_b20503d2c02942dca278e712a68')->references('id')->on('users');
            $table->foreign('patients_id', 'FK_edfb50e8e307011a7d5e7440879')->references('id')->on('patients');
        });
    }

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