<?php

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

class AddColumnsInCategoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('categories', function (Blueprint $table) {
            if (!Schema::hasColumn('categories', 'pos')) {
                $table->integer('pos')->nullable()->after('status');
            }
            if (!Schema::hasColumn('categories', 'poss')) {
                $table->integer('poss')->nullable()->after('pos');
            }
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('categories', function (Blueprint $table) {
            if (Schema::hasColumn('categories', 'pos')) {
                $table->dropColumn('pos');
            }
            if (Schema::hasColumn('categories', 'poss')) {
                $table->dropColumn('poss');
            }
        });
    }
}
