<?php

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

class UpdateNewsItem extends Migration
{

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('news_items', function (Blueprint $table) {
            $table->string('video_position', 20)->nullable();

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

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('news_items', function (Blueprint $table) {
            $table->dropColumn('video_position');

            $table->dropForeign(['video_id']);
            $table->dropColumn('video_id');
        });
    }
}
