<?php

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

class CreateUploadPhotosTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('upload_photos', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedInteger('upload_id');
            $table->unsignedBigInteger('photo_id');
            $table->timestamps();

            $table->foreign('upload_id')
                  ->references('id')->on('uploads')
                  ->onDelete('cascade');
            $table->foreign('photo_id')
                ->references('id')->on('photos')
                ->onDelete('cascade');
        });
    }

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