complere story 11.1 with qa tests

This commit is contained in:
Naser Mansour
2026-01-03 19:06:21 +02:00
parent 393acde340
commit f32ea2b68d
6 changed files with 444 additions and 23 deletions
@@ -0,0 +1,39 @@
<?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::table('consultations', function (Blueprint $table) {
// Make user_id nullable for guest consultations
$table->foreignId('user_id')->nullable()->change();
// Add guest fields after user_id
$table->string('guest_name', 255)->nullable()->after('user_id');
$table->string('guest_email', 255)->nullable()->after('guest_name');
$table->string('guest_phone', 50)->nullable()->after('guest_email');
// Index for 1-per-day guest lookup performance
$table->index('guest_email');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('consultations', function (Blueprint $table) {
$table->dropIndex(['guest_email']);
$table->dropColumn(['guest_name', 'guest_email', 'guest_phone']);
// Note: Cannot safely restore NOT NULL if guest records exist
});
}
};