<?php

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

class CreateContactsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('contacts', function (Blueprint $table) {
            $table->id();
            $table->morphs('owner');
            $table->string('reference');
            $table->string('phone', '45')->nullable();
            $table->string('email')->nullable();
            $table->string('wechat_id', '45')->nullable();
            $table->integer('default')->default(false);
            $table->softDeletes();
            $table->timestamps();
        });

        Schema::table('contacts', function (Blueprint $table) {
            $table->string('owner_type', 191)->change();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('contacts');
    }
}
