<?php

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

/**
 * PRC-1143 — konsolide şema: `communication_template_contents` tablosunun TAM tanımı (tek dosya).
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::create('communication_template_contents', function (Blueprint $t) {
            $t->id();
            $t->unsignedBigInteger('template_id');
            $t->string('language', 5)->default('tr');
            $t->string('subject', 255)->nullable();
            $t->text('content');
            $t->timestamp('created_at')->nullable();
            $t->timestamp('updated_at')->nullable();
            $t->unique(['template_id', 'language'], 'communication_template_contents_template_id_language_unique');
            $t->foreign('template_id', 'communication_template_contents_template_id_foreign')->references('id')->on('communication_templates')->onDelete('cascade');
        });
    }

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