2026-05-26 08:14:29 +02:00
|
|
|
<?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
|
|
|
|
|
{
|
2026-06-17 19:13:40 +02:00
|
|
|
if (!Schema::hasTable('eventi')) {
|
|
|
|
|
Schema::create('eventi', function (Blueprint $table) {
|
|
|
|
|
$table->id();
|
|
|
|
|
$table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null');
|
|
|
|
|
$table->string('nome_evento');
|
|
|
|
|
$table->string('tipo_evento')->nullable();
|
|
|
|
|
$table->enum('tipo_recorrenza', ['singolo', 'ricorrente'])->default('singolo');
|
|
|
|
|
$table->unsignedTinyInteger('giorno_settimana')->nullable();
|
|
|
|
|
$table->time('ora_inizio')->nullable();
|
|
|
|
|
$table->date('data_specifica')->nullable();
|
|
|
|
|
$table->unsignedInteger('durata_minuti')->nullable();
|
|
|
|
|
$table->text('descrizione')->nullable();
|
|
|
|
|
$table->text('note')->nullable();
|
|
|
|
|
$table->timestamps();
|
|
|
|
|
$table->index('tenant_id');
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-05-26 08:14:29 +02:00
|
|
|
|
2026-06-17 19:13:40 +02:00
|
|
|
if (!Schema::hasTable('eventi_gruppi')) {
|
|
|
|
|
Schema::create('eventi_gruppi', function (Blueprint $table) {
|
|
|
|
|
$table->id();
|
|
|
|
|
$table->foreignId('evento_id')->constrained('eventi')->onDelete('cascade');
|
|
|
|
|
$table->foreignId('gruppo_id')->constrained('gruppi')->onDelete('cascade');
|
|
|
|
|
$table->timestamps();
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-05-26 08:14:29 +02:00
|
|
|
|
2026-06-17 19:13:40 +02:00
|
|
|
if (!Schema::hasTable('eventi_responsabili')) {
|
|
|
|
|
Schema::create('eventi_responsabili', function (Blueprint $table) {
|
|
|
|
|
$table->id();
|
|
|
|
|
$table->foreignId('evento_id')->constrained('eventi')->onDelete('cascade');
|
|
|
|
|
$table->foreignId('individuo_id')->constrained('individui')->onDelete('cascade');
|
|
|
|
|
$table->timestamps();
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-05-26 08:14:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function down(): void
|
|
|
|
|
{
|
|
|
|
|
Schema::dropIfExists('eventi_responsabili');
|
|
|
|
|
Schema::dropIfExists('eventi_gruppi');
|
|
|
|
|
Schema::dropIfExists('eventi');
|
|
|
|
|
}
|
|
|
|
|
};
|