39 lines
1.3 KiB
PHP
39 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('letters', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
|
|
$table->foreignId('project_id')->nullable()->constrained()->nullOnDelete();
|
|
$table->enum('type', ['incoming', 'outgoing']);
|
|
$table->string('subject');
|
|
$table->text('content')->nullable();
|
|
$table->string('sender');
|
|
$table->string('recipient');
|
|
$table->date('letter_date');
|
|
$table->string('reference_number')->nullable();
|
|
$table->foreignId('parent_letter_id')->nullable()->constrained('letters')->nullOnDelete();
|
|
$table->enum('status', ['draft', 'sent', 'received', 'archived'])->default('draft');
|
|
$table->timestamps();
|
|
|
|
$table->index('tenant_id');
|
|
$table->index('project_id');
|
|
$table->index('type');
|
|
$table->index('status');
|
|
$table->index('letter_date');
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('letters');
|
|
}
|
|
};
|