<?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('photo_tag', function(Blueprint $table)
		{
			$table->id();
			$table->timestamps();
			$table->bigInteger('tag_id');
			$table->foreign('tag_id')->references('id')->on('tags');
			$table->bigInteger('photo_id');
			$table->foreign('photo_id')->references('id')->on('photos');

			$table->unique(['photo_id','tag_id']);
		});
	}

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