<?php

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

class CreateMensagenschatsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('mensagenschats', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_from');
            $table->foreignId('user_to');

            $table->text('mensagem')->nullable();
            $table->enum('tipo',['normal','ficheiro','chamadaaudio','chamadavideo'])->default('normal');
            $table->enum('estado',['lido','naolido'])->default('naolido');

            $table->string('file')->nullable();
            $table->foreign('user_from')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');
            $table->foreign('user_to')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');

            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('mensagenschats', function(Blueprint $table)
        {
            $table->dropSoftDeletes();
        });
        Schema::dropIfExists('mensagenschats');
    }
}
