<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('artist_song', function (Blueprint $table) {
            $table->unsignedBigInteger('song_id');
            $table->unsignedBigInteger('artist_id');
            
            $table->foreign('song_id')->references('id')->on('songs')->restrictOnDelete()->restrictOnUpdate();
            $table->foreign('artist_id')->references('id')->on('artists')->restrictOnDelete()->restrictOnUpdate();
            $table->primary(['song_id', 'artist_id']);
        });
    }

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