Teren-app/database/migrations/2025_10_25_000001_create_packages_table.php
2025-10-26 12:57:09 +01:00

38 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('packages', function (Blueprint $table) {
$table->id();
$table->uuid('uuid')->unique();
$table->string('type'); // sms, email, archive, segment
$table->string('status')->default('draft'); // draft, queued, running, completed, failed, canceled
$table->string('name')->nullable();
$table->text('description')->nullable();
$table->json('meta')->nullable();
$table->unsignedInteger('total_items')->default(0);
$table->unsignedInteger('processing_count')->default(0);
$table->unsignedInteger('sent_count')->default(0);
$table->unsignedInteger('failed_count')->default(0);
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamp('finished_at')->nullable();
$table->timestamps();
$table->index(['type', 'status']);
$table->index(['created_by']);
$table->index(['finished_at']);
});
}
public function down(): void
{
Schema::dropIfExists('packages');
}
};