<?php

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

class CreateCollectSpendCyclesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('collect_spend_cycles', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('collect_spend_id')->nullable();
            $table->integer('repeat_every')->nullable();
            $table->integer('repeat_every_custom')->nullable();
            $table->tinyInteger('repeat_type_custom')->nullable();
            $table->integer('cycles')->nullable();
            $table->boolean('unlimited_cycles')->default(false);
            $table->timestamps();
        });

        Schema::create('collect_spend_cycle_logs', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('collect_spend_id')->nullable();
            $table->text('content')->nullable();
            $table->dateTime('last_processed_at')->nullable();
            $table->integer('remain_cycle')->nullable();
            $table->timestamps();
        });
    }

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