<?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::disableForeignKeyConstraints();

        Schema::create('news_photos', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('news_paragraph_id')->index();
            $table->foreign('news_paragraph_id')->references('id')->on('news_paragraphs')->comment("關聯文章段落");
            $table->string('image_url')->nullable()->comment("圖片網址");
            $table->json('image_alt')->nullable()->comment("圖片註釋");
            $table->unsignedInteger('order')->default(0)->comment("排序");
        });

        Schema::enableForeignKeyConstraints();
    }

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