<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use MtcPharmacy\Subscriptions\Classes\Subscription;

class AddIsRequiredField extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('subscription_options', function (Blueprint $table) {
            if (!Schema::hasColumn('subscription_options', 'is_required')) {
                $table->boolean('is_required')->after('is_allowed')->default(0);
            }
        });
    }

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

