<?php

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

class CreateFamilyUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('family_users', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id');
            $table->enum('type', ['Pareja', 'Hijo']);
            $table->string('first_name');
            $table->string('last_name');
            $table->enum('document_type', ['1', '2', '3','4']);
            $table->string('document',15);
            $table->date('birth_date');
            $table->string('education_level')->nullable();
            $table->string('occupation')->nullable();
            $table->string('phone')->nullable();
            $table->unsignedBigInteger('eps_id')->nullable();
            $table->string('support_document')->nullable();
            $table->foreign('eps_id')
                    ->references('id')->on('public_health_entities')
                    ->onUpdate('cascade')
                    ->onDelete('cascade');
            $table->timestamps();
        });
    }

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