<?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::table('pricelist_file_lines', function (Blueprint $table) {
            $table->foreignId('product_id')->nullable()->constrained('products')->nullOnDelete();
            $table->foreignId('product_group_id')->nullable()->constrained('product_groups')->nullOnDelete();
            $table->foreignId('producer_id')->nullable()->constrained('producers')->nullOnDelete();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('pricelist_file_lines', function (Blueprint $table) {
            $table->dropForeign(['product_id']);
            $table->dropForeign(['product_group_id']);
            $table->dropForeign(['producer_id']);
            $table->dropColumn(['product_id', 'product_group_id', 'producer_id']);
        });
    }
};
