<?php

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

class AddNameToLaravelCrmCustomersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table(config('laravel-crm.db_table_prefix').'customers', function (Blueprint $table) {
            $table->string('name')->after('customerable_id')->nullable();
            $table->string('customerable_type')->nullable()->change();
            $table->unsignedBigInteger('customerable_id')->nullable()->change();
        });  
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table(config('laravel-crm.db_table_prefix').'customers', function (Blueprint $table) {
            $table->dropColumn(['name']);
            $table->string('customerable_type')->nullable(false)->change();
            $table->unsignedBigInteger('customerable_id')->nullable(false)->change();
        });
    }
}
