<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('artwork_category', function (Blueprint $table) {

            $table->unsignedBigInteger('artwork_id');
            $table->unsignedBigInteger('category_id');

            $table->primary(['artwork_id', 'category_id']);

            $table->foreign('category_id')
                ->references('id')
                ->on('categories')
                ->cascadeOnDelete();

        });
    }

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