Step 2: Data models and migrations (Email, EmailBody, factories)

This commit is contained in:
idevakk
2026-03-05 14:00:12 +05:30
parent 92b243e3ad
commit 2491be9809
6 changed files with 246 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
<?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::create('emails', function (Blueprint $table) {
$table->id();
$table->char('unique_id_hash', 64);
$table->string('recipient_email');
$table->string('recipient_name')->default('');
$table->string('sender_email');
$table->string('sender_name')->default('');
$table->string('domain');
$table->string('subject', 500)->default('');
$table->string('preview', 500)->default('');
$table->json('attachments_json')->nullable();
$table->unsignedBigInteger('attachment_size')->default(0);
$table->boolean('is_read')->default(false);
$table->timestamp('received_at')->nullable();
$table->timestamps();
$table->unique('unique_id_hash', 'idx_unique_hash');
$table->index('recipient_email', 'idx_recipient');
$table->index('domain', 'idx_domain');
$table->index('created_at', 'idx_created_at');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('emails');
}
};