<?php

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

class CreateTableUserFeedPurchase extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_feed_purchase', function (Blueprint $table) {
            $table->primary(['user_id', 'feed_id']);
            $table->unsignedBigInteger('user_id');
            $table->unsignedBigInteger('feed_id');
            //$table->unsignedInteger('amount');
            $table->decimal('amount', 15, 2)->nullable();

            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->foreign('feed_id')->references('id')->on('feeds')->onDelete('cascade');
            $table->timestamps();
        });
    }

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