53 lines
1.8 KiB
PHP
53 lines
1.8 KiB
PHP
<?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('events', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('source_id')->constrained('sources')->cascadeOnDelete();
|
|
$table->string('external_id')->nullable(); // ID aus der externen Quelle
|
|
$table->string('title');
|
|
$table->text('description')->nullable();
|
|
$table->string('location'); // Ort/Stadt
|
|
$table->string('category')->nullable(); // z.B. "Kultur", "Sport", "Bildung"
|
|
$table->string('slug')->unique();
|
|
$table->string('image_url')->nullable();
|
|
$table->string('website_url')->nullable();
|
|
$table->string('contact_email')->nullable();
|
|
$table->string('contact_phone')->nullable();
|
|
$table->enum('status', ['draft', 'published', 'archived'])->default('published');
|
|
$table->timestamps();
|
|
$table->softDeletes();
|
|
|
|
$table->engine = 'InnoDB';
|
|
$table->charset = 'utf8mb4';
|
|
$table->collation = 'utf8mb4_unicode_ci';
|
|
|
|
// Indizes für Performance
|
|
$table->index('source_id');
|
|
$table->index('slug');
|
|
$table->index(['location', 'status']); // Composite Index
|
|
$table->index(['category', 'status']);
|
|
$table->index('created_at');
|
|
$table->unique(['source_id', 'external_id']); // Verhindert Duplikate aus gleicher Quelle
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('events');
|
|
}
|
|
};
|