physiotherapy-clinic/database/migrations/2024_01_01_000013_create_reminders_table.php

42 lines
1.5 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('reminder_templates', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->text('content'); // with placeholders like {patient_name}, {date}, {time}, {therapist_name}
$table->enum('channel', ['sms', 'whatsapp', 'email', 'internal']);
$table->integer('hours_before')->default(24);
$table->boolean('is_active')->default(true);
$table->timestamps();
});
Schema::create('reminders', function (Blueprint $table) {
$table->id();
$table->foreignId('appointment_id')->constrained('appointments');
$table->foreignId('template_id')->nullable()->constrained('reminder_templates');
$table->enum('channel', ['sms', 'whatsapp', 'email', 'internal']);
$table->text('content');
$table->timestamp('send_at');
$table->timestamp('sent_at')->nullable();
$table->enum('status', ['queued', 'sent', 'failed'])->default('queued');
$table->text('error_message')->nullable();
$table->text('response')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('reminders');
Schema::dropIfExists('reminder_templates');
}
};