<?php

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

class CreatePremiaTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('premia', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('cover_id')->nullable();
            $table->unsignedBigInteger('sponsor_id');
            $table->unsignedBigInteger('member_id')->nullable();  
            $table->decimal('amount')->nullable();
            $table->decimal('new_amount')->nullable();        
            $table->timestamps();
            $table->softDeletes();
            $table->foreign('cover_id')->references('id')->on('covers')->onDelete('cascade');
            $table->foreign('sponsor_id')->references('id')->on('sponsors')->onDelete('cascade');
            $table->foreign('member_id')->references('id')->on('members')->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
       // Schema::dropIfExists('premia');
       Schema::table('premia', function (Blueprint $table) {
        $table->dropSoftDeletes();
    });
    }
}
