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

37 lines
1.3 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('treatments', function (Blueprint $table) {
$table->id();
$table->foreignId('patient_id')->constrained('patients');
$table->foreignId('appointment_id')->nullable()->constrained('appointments');
$table->foreignId('user_id')->constrained('users'); // therapist
$table->string('treatment_code')->unique();
$table->string('name');
$table->text('description')->nullable();
$table->integer('sessions_count')->default(1);
$table->integer('sessions_completed')->default(0);
$table->date('start_date');
$table->date('end_date')->nullable();
$table->enum('status', ['planned', 'in_progress', 'completed', 'cancelled'])->default('planned');
$table->decimal('total_cost', 15, 2)->default(0);
$table->foreignId('currency_id')->constrained('currencies');
$table->text('notes')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('treatments');
}
};