<?php

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

class SentReports extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::dropIfExists('pending_reports');
        Schema::create('pending_reports', function (Blueprint $table) {

            $table->id();

            $table->timestamps();
            $table->softDeletes();

            $table->unsignedBigInteger('report_id')->nullable();

            $table->unsignedMediumInteger('year')->nullable();
            $table->unsignedTinyInteger('quarter')->nullable();
            $table->unsignedTinyInteger('month')->nullable();
            $table->unsignedTinyInteger('week')->nullable();
            $table->unsignedSmallInteger('day')->nullable();

            $table->enum('report_type', ['singular', 'daily', 'weekly', 'monthly', 'quarterly', 'yearly', 'carpet', 'other_1', 'other_2', 'other_3', 'other_4']);
            $table->enum('status', ['denied', 'approval', 'pending', 'sent', 'not-send', 'other_1', 'other_2', 'other_3', 'other_4']);
            $table->string('path')->unique();

            $table->index('report_id');
            $table->index('report_type');

            $table->foreignId('organisation_id')->cascadeOnDelete()->constrained('organisations');
        });
    }

    public function down() {
        Schema::dropIfExists('pending_reports');
    }
}
