<?php

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

class CreatePressReleasesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('press_releases', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('backend_user_id')->nullable();
            $table->foreign('backend_user_id')->references('id')
                ->on('backend_users')->onDelete('SET NULL')->onUpdate('CASCADE');
            $table->nullableTimestamps();

            $table->string('date', 150)->nullable();

            // Topic
            $table->unsignedBigInteger('topic_id')->nullable();
            $table->foreign('topic_id')->references('id')
                ->on('topics')->onDelete('SET NULL')->onUpdate('CASCADE');

            // Country
            $table->unsignedBigInteger('country_id')->nullable();
            $table->foreign('country_id')->references('id')
                ->on('countries')->onDelete('SET NULL')->onUpdate('CASCADE');

            // Image
            $table->unsignedBigInteger('image_id')->nullable();
            $table->foreign('image_id')->references('id')
                ->on('media_items')->onDelete('SET NULL')->onUpdate('CASCADE');

            // imageMobile
            $table->unsignedBigInteger('image_mobile_id')->nullable();
            $table->foreign('image_mobile_id')->references('id')
                ->on('media_items')->onDelete('SET NULL')->onUpdate('CASCADE');

            // document
            $table->unsignedBigInteger('document_id')->nullable();
            $table->foreign('document_id')->references('id')
                ->on('media_items')->onDelete('SET NULL')->onUpdate('CASCADE');
        });
    }
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('press_releases');
    }
}
