<?php

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

return new class extends Migration
{
    public function up()
    {
        Schema::create('product_documents', function (Blueprint $table) {
            $table->id();
            $table->foreignId('product_id')->constrained();
            $table->string('title');
            $table->string('type'); // manual, guide, specification
            $table->string('file_path');
            $table->string('file_type');
            $table->integer('file_size');
            $table->string('language')->default('en');
            $table->integer('version')->default(1);
            $table->timestamps();
        });

        Schema::create('document_downloads', function (Blueprint $table) {
            $table->id();
            $table->foreignId('document_id')->constrained('product_documents');
            $table->foreignId('user_id')->nullable()->constrained();
            $table->string('ip_address');
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::dropIfExists('document_downloads');
        Schema::dropIfExists('product_documents');
    }
};