<?php

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

class CreateVcReminderTemplatesTable extends Migration
{
    public function up()
    {
        if (!Schema::hasTable('vc_reminder_templates')) {
            Schema::create('vc_reminder_templates', function (Blueprint $table) {
                $table->increments('id');
                $table->unsignedInteger('business_id')->nullable()
                      ->comment('NULL = system default, set to business_id for customised copy');
                $table->enum('type', ['email_due', 'email_overdue', 'wa_due', 'wa_overdue']);
                $table->string('name', 100);
                $table->string('subject', 255)->nullable()->comment('Email subject (null for WA)');
                $table->text('body');
                $table->boolean('is_active')->default(true);
                $table->boolean('is_system_default')->default(false);
                $table->timestamps();
            });
        }
    }

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