<?php

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

class AddForeignKeysToFeedItemStatesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('feed_item_states', function (Blueprint $table) {
            $table->foreign('document_id')->references('id')->on('documents')->onDelete('CASCADE');
            $table->foreign('feed_id')->references('id')->on('feeds')->onDelete('CASCADE');
            $table->foreign('feed_item_id')->references('id')->on('feed_items')->onDelete('CASCADE');
            $table->foreign('user_id')->references('id')->on('users')->onDelete('CASCADE');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('feed_item_states', function (Blueprint $table) {
            $table->dropForeign('feed_item_states_document_id_foreign');
            $table->dropForeign('feed_item_states_feed_id_foreign');
            $table->dropForeign('feed_item_states_feed_item_id_foreign');
            $table->dropForeign('feed_item_states_user_id_foreign');
        });
    }
}
