<?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_subscription_payments', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('company_subscription_id')->index();
            $table->bigInteger('company_id')->index();
            $table->bigInteger('subscription_rate_id')->index();
            $table->string('customer_id', 255);
            $table->string('charge_id', 255);
            $table->bigInteger('user_id')->index();
            $table->string('invoice_no', 150)->unique();
            $table->date('duration');
            $table->date('month_paid');
            $table->enum('mode_of_payment', ['monthly', 'yearly']);
            $table->decimal('rate', 10, 2);
            $table->decimal('balance', 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->float('amount_paid');
            $table->float('total_paid');
            $table->float('additional_penalty_charge')->nullable();
            $table->enum('type', ['subscribe', 'upgrade', 'renew', 'monthly']);
            $table->timestamps();
            $table->softDeletes();
        });
    }

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