<?php

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

class UpdateCustomerAppealTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('customer_appeals', function (Blueprint $table) {
            if (!Schema::hasColumn('customer_appeals', 'planning_id')) {
                $table->integer('planning_id')->unsigned()->nullable();
                $table->foreign('planning_id', '329913_5d52dd17602a4')
                    ->references('id')->on('plannings')->onDelete('set null');
            }
            if (!Schema::hasColumn('customer_appeals', 'name')) {
                $table->string('name')->nullable();
            }
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('customer_appeals', function (Blueprint $table) {
            $table->dropColumn('name');
            $table->dropForeign('planning_id');
            $table->dropColumn('planning_id');
        });
    }
}
