<?php

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

class CreateNewsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('news', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger("company_id")->nullable();
            $table->unsignedBigInteger("box_id")->nullable();
            $table->string("title");
            $table->longText("description");
            $table->timestamps();

            $table->foreign("company_id")->on("companies")->references("id")->onDelete("cascade");
            $table->foreign("box_id")->on("boxes")->references("id")->onDelete("cascade");
        });
    }

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