<?php

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

class AddFieldsToGoodsTypes extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasColumns('goods_types', ['parent_id', 'show',"level"])) {
            return;
        }
        Schema::table('goods_types', function (Blueprint $table) {
            $table->integer('parent_id')->default(0)->comment('父id');
            $table->integer('show')->default(1)->comment('是否显示 0隐藏 1显示');
            $table->integer('level')->default(1)->comment('层级 目前仅记录使用 默认1');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('goods_types', function (Blueprint $table) {
            //
            $table->dropColumn('parent_id');
            $table->dropColumn('show');
            $table->dropColumn('level');
        });
    }
}
