<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('company_subscriptions', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->tinyInteger('subscription_rate_id')->index();
            $table->bigInteger('company_id')->index();
            $table->string('customer_id', 255);
            $table->string('invoice_no', 150)->unique();
            $table->enum('mode_of_payment', ['monthly', 'yearly']);
            $table->decimal('rate', 10, 2);
            $table->decimal('discount', 10, 2);
            $table->decimal('previous_bill', 10, 2);
            $table->decimal('current_bill', 10, 2);
            $table->decimal('penalty_charge', 10, 2);
            $table->decimal('amount_due', 10, 2);
            $table->decimal('amount_paid', 10, 2);
            $table->decimal('balance', 10, 2)->nullable();
            $table->float('total_paid');
            $table->dateTime('date_subscribed');
            $table->dateTime('duration');
            $table->dateTime('current_month_paid')->nullable();
            $table->dateTime('date_upgraded')->nullable();
            $table->dateTime('date_renewed')->nullable();
            $table->enum('is_blocked', ['true', 'false'])->default('false');
            $table->enum('is_expired', ['true', 'false'])->default('false');
            $table->enum('is_monthly_expired', ['true', 'false'])->default('false');
            $table->timestamps();
            $table->softDeletes();
        });
    }

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