<?php

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

class CreateCouponsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //
        Schema::create('coupons', function(Blueprint $table) {
           $table->increments('id');
           $table->text('name')->nullable();
           $table->integer('number')->default(1);
           $table->integer('number_month_more')->default(0);
           $table->string('package_ids')->nullable();
           $table->boolean('is_upgrade_package')->default(false);
           $table->date('from_date_expire')->nullable();
           $table->date('end_date_expire')->nullable();
           $table->integer('number_use')->default(1);
           $table->text('note')->nullable();
           $table->timestamps();
           $table->softDeletes();
        });

        Schema::create('log_coupons', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->nullable();
            $table->integer('coupon_id')->nullable();
            $table->integer('coupon_generate_id')->nullable();
            $table->string('code')->nullable();
            $table->timestamps();
        });

        Schema::create('coupon_generates', function(Blueprint $table) {
           $table->increments('id');
           $table->integer('coupon_id')->nullable();
           $table->string('code')->nullable();
           $table->timestamps();
        });
    }

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