<?php

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

class CreateFilesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('files', function (Blueprint $table) {
            $table->string('id')->primary();
            $table->string('history_id');
            $table->string('control_history_id')->nullable();
            $table->string('friendly_name');
            $table->string('extension', 45);
            $table->text('path');
            $table->timestamp('created_at')->useCurrent();
            $table->timestamp('updated_at')->nullable();
            
            $table->foreign('control_history_id', 'FK_1ca353aab9f53e52f005d9b5913')->references('id')->on('control_history');
            $table->foreign('history_id', 'FK_bef9a9de068f9f70d3eb458447c')->references('id')->on('history');
        });
    }

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