<?php

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

class BillingOverages extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {

        Schema::create('billing_commits', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            $table->softDeletes();

            $table->timestamp('effective_at');
            $table->tinyInteger('billing_day');
            $table->unsignedBigInteger('commit');
            $table->decimal('price_per_unit', 10, 5, true);
            $table->string('currency');

            $table->string('search_name');
            $table->string('search_service');
            $table->string('search_brand');

            // This is a bit gross but required - Accounts may not be in Creatia, but Sean still needs this functionality.
            $table->string('whmcs_brand');
            $table->unsignedBigInteger('whmcs_client_id');
            $table->unsignedBigInteger('whmcs_service_id');
        });

        Schema::create('invoices', function (Blueprint $table) {
            $table->id();
            $table->timestamps();

            $table->tinyInteger('month');
            $table->timestamp('start');
            $table->timestamp('finish');

            $table->string('whmcs_brand');
            $table->unsignedBigInteger('whmcs_client_id');
            $table->unsignedBigInteger('whmcs_service_id');
        });

    }

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