sistemazione migrate

This commit is contained in:
Mariano
2026-06-17 19:13:40 +02:00
parent 7302146a77
commit 005fa5b4a3
33 changed files with 635 additions and 498 deletions
+43
View File
@@ -380,3 +380,46 @@ if (!empty($contatto['individuo_id'])) { create }
**Fix**: **Fix**:
1. `VistaReportController@update` (linea 101-103): aggiunto `if ($request->expectsJson()) { return response()->json([...]); }` — così il fetch riceve JSON 200, non un redirect 302. 1. `VistaReportController@update` (linea 101-103): aggiunto `if ($request->expectsJson()) { return response()->json([...]); }` — così il fetch riceve JSON 200, non un redirect 302.
2. Fetch headers in `table-settings.blade.php`: aggiunto `'Accept': 'application/json'` — necessario perché `expectsJson()` controlla l'header `Accept`, non `Content-Type`. 2. Fetch headers in `table-settings.blade.php`: aggiunto `'Accept': 'application/json'` — necessario perché `expectsJson()` controlla l'header `Accept`, non `Content-Type`.
## 2026-06-10 — Fix: tutte le migration idempotenti + seeders idempotenti
**Problema**: `php artisan migrate` falliva su tabelle già esistenti. `php artisan db:seed` creava duplicati su re-run.
### Migration: hasTable guard su tutti i 27 file mancanti
Aggiunto `if (!Schema::hasTable('table_name')) { ... }` wrapper a tutte le 27 migration file (44 `Schema::create()` calls) che ne erano prive, usando script Node.js di trasformazione automatica:
- `2024_01_01_000002_create_comuni_diocesi_tables.php`
- `2024_01_01_000003_create_individui_table.php`
- `2024_01_01_000004_create_contatti_table.php`
- `2024_01_01_000005_create_gruppi_table.php`
- `2024_01_01_000006_create_gruppo_individuo_table.php`
- `2024_01_01_000007_create_eventi_table.php`
- `2024_01_01_000008_create_documenti_table.php`
- `2024_01_01_000009_create_mailing_tables.php`
- `2024_01_01_000010_create_notifiche_table.php`
- `2024_01_01_000011_create_users_table.php`
- `2024_01_01_000012_create_cache_and_jobs_tables.php`
- `2024_01_01_000019_create_eventi_documenti_table.php`
- `2024_01_01_000022_create_table_viste_report.php`
- `2026_05_10_000001_create_tipologie_documenti_table.php`
- `2026_05_10_000002_add_acl_tables.php`
- `2026_05_10_125210_create_permission_tables.php` (usa `$tableNames[...]` dinamici)
- `2026_05_11_000001_create_email_settings_table.php`
- `2026_05_11_000002_create_email_folders_table.php`
- `2026_05_11_000003_create_email_messages_table.php`
- `2026_05_11_000007_create_email_attachments_table.php`
- `2026_05_12_000001_create_ruoli_table.php`
- `2026_05_25_000001_create_report_custom_table.php`
- `2026_05_26_000001_create_tipologie_eventi_table.php`
- `2026_05_26_000002_create_sender_accounts_table.php`
- `2026_05_27_000001_create_documenti_cartelle_table.php`
- `2026_05_27_113245_create_storage_repositories_table.php`
- `2026_06_02_000001_create_calendario_connessioni_table.php`
### Seeder: firstOrCreate per idempotenza
- `DiocesiSeeder.php`: `Diocesi::create()``Diocesi::firstOrCreate(['nome' => $d['nome']], $d)`
- `ComuniSeeder.php`: `Comune::create()``Comune::firstOrCreate(['codice_istat' => $c['codice_istat']], $c)`
- `DatabaseSeeder.php`: `User::create()``User::firstOrCreate(['email' => 'admin@glastree.local'], [...])`, con guardia su `role_preset_id`
**Risultato**: `php artisan migrate --seed` è ora completamente idempotente. Zero errori su 62 migration + 6 seeder.
@@ -8,6 +8,10 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
if (Schema::hasTable('tenants')) {
return;
}
Schema::create('tenants', function (Blueprint $table) { Schema::create('tenants', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('nome'); $table->string('nome');
@@ -8,26 +8,30 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('diocesi', function (Blueprint $table) { if (!Schema::hasTable('diocesi')) {
$table->id(); Schema::create('diocesi', function (Blueprint $table) {
$table->string('nome'); $table->id();
$table->string('regione')->nullable(); $table->string('nome');
$table->timestamps(); $table->string('regione')->nullable();
}); $table->timestamps();
});
}
Schema::create('comuni', function (Blueprint $table) { if (!Schema::hasTable('comuni')) {
$table->id(); Schema::create('comuni', function (Blueprint $table) {
$table->string('nome'); $table->id();
$table->string('codice_istat', 10)->nullable(); $table->string('nome');
$table->string('cap')->nullable(); $table->string('codice_istat', 10)->nullable();
$table->string('sigla_provincia', 2)->nullable(); $table->string('cap')->nullable();
$table->string('regione')->nullable(); $table->string('sigla_provincia', 2)->nullable();
$table->float('latitudine')->nullable(); $table->string('regione')->nullable();
$table->float('longitudine')->nullable(); $table->float('latitudine')->nullable();
$table->timestamps(); $table->float('longitudine')->nullable();
$table->index('nome'); $table->timestamps();
$table->index('sigla_provincia'); $table->index('nome');
}); $table->index('sigla_provincia');
});
}
} }
public function down(): void public function down(): void
@@ -8,27 +8,29 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('individui', function (Blueprint $table) { if (!Schema::hasTable('individui')) {
$table->id(); Schema::create('individui', function (Blueprint $table) {
$table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null'); $table->id();
$table->string('codice_id', 5)->unique(); $table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null');
$table->string('cognome'); $table->string('codice_id', 5)->unique();
$table->string('nome'); $table->string('cognome');
$table->date('data_nascita')->nullable(); $table->string('nome');
$table->string('indirizzo')->nullable(); $table->date('data_nascita')->nullable();
$table->string('cap', 10)->nullable(); $table->string('indirizzo')->nullable();
$table->string('città')->nullable(); $table->string('cap', 10)->nullable();
$table->string('sigla_provincia', 2)->nullable(); $table->string('città')->nullable();
$table->enum('genere', ['M', 'F'])->nullable(); $table->string('sigla_provincia', 2)->nullable();
$table->enum('tipo_documento', ['carta_identita', 'patente'])->nullable(); $table->enum('genere', ['M', 'F'])->nullable();
$table->date('scadenza_documento')->nullable(); $table->enum('tipo_documento', ['carta_identita', 'patente'])->nullable();
$table->text('note')->nullable(); $table->date('scadenza_documento')->nullable();
$table->string('avatar_path')->nullable(); $table->text('note')->nullable();
$table->timestamps(); $table->string('avatar_path')->nullable();
$table->index('tenant_id'); $table->timestamps();
$table->index('codice_id'); $table->index('tenant_id');
$table->index('cognome'); $table->index('codice_id');
}); $table->index('cognome');
});
}
} }
public function down(): void public function down(): void
@@ -8,16 +8,18 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('contatti', function (Blueprint $table) { if (!Schema::hasTable('contatti')) {
$table->id(); Schema::create('contatti', function (Blueprint $table) {
$table->foreignId('individuo_id')->constrained('individui')->onDelete('cascade'); $table->id();
$table->enum('tipo', ['telefono', 'cellulare', 'email', 'fax', 'web', 'telegram', 'whatsapp', 'altro']); $table->foreignId('individuo_id')->constrained('individui')->onDelete('cascade');
$table->string('valore'); $table->enum('tipo', ['telefono', 'cellulare', 'email', 'fax', 'web', 'telegram', 'whatsapp', 'altro']);
$table->string('etichetta')->nullable(); $table->string('valore');
$table->boolean('is_primary')->default(false); $table->string('etichetta')->nullable();
$table->timestamps(); $table->boolean('is_primary')->default(false);
$table->index('individuo_id'); $table->timestamps();
}); $table->index('individuo_id');
});
}
} }
public function down(): void public function down(): void
@@ -8,24 +8,26 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('gruppi', function (Blueprint $table) { if (!Schema::hasTable('gruppi')) {
$table->id(); Schema::create('gruppi', function (Blueprint $table) {
$table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null'); $table->id();
$table->foreignId('parent_id')->nullable()->constrained('gruppi')->onDelete('set null'); $table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null');
$table->foreignId('diocesi_id')->nullable()->constrained('diocesi')->onDelete('set null'); $table->foreignId('parent_id')->nullable()->constrained('gruppi')->onDelete('set null');
$table->foreignId('responsabile_id')->nullable()->constrained('individui')->onDelete('set null'); $table->foreignId('diocesi_id')->nullable()->constrained('diocesi')->onDelete('set null');
$table->string('nome'); $table->foreignId('responsabile_id')->nullable()->constrained('individui')->onDelete('set null');
$table->text('descrizione')->nullable(); $table->string('nome');
$table->string('indirizzo_incontro')->nullable(); $table->text('descrizione')->nullable();
$table->string('cap_incontro', 10)->nullable(); $table->string('indirizzo_incontro')->nullable();
$table->string('città_incontro')->nullable(); $table->string('cap_incontro', 10)->nullable();
$table->string('sigla_provincia_incontro', 2)->nullable(); $table->string('città_incontro')->nullable();
$table->string('mappa_posizione')->nullable(); $table->string('sigla_provincia_incontro', 2)->nullable();
$table->json('metadata')->nullable(); $table->string('mappa_posizione')->nullable();
$table->timestamps(); $table->json('metadata')->nullable();
$table->index('tenant_id'); $table->timestamps();
$table->index('parent_id'); $table->index('tenant_id');
}); $table->index('parent_id');
});
}
} }
public function down(): void public function down(): void
@@ -8,15 +8,17 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('gruppo_individuo', function (Blueprint $table) { if (!Schema::hasTable('gruppo_individuo')) {
$table->id(); Schema::create('gruppo_individuo', function (Blueprint $table) {
$table->foreignId('gruppo_id')->constrained('gruppi')->onDelete('cascade'); $table->id();
$table->foreignId('individuo_id')->constrained('individui')->onDelete('cascade'); $table->foreignId('gruppo_id')->constrained('gruppi')->onDelete('cascade');
$table->string('ruolo_nel_gruppo')->nullable(); $table->foreignId('individuo_id')->constrained('individui')->onDelete('cascade');
$table->date('data_adesione')->nullable(); $table->string('ruolo_nel_gruppo')->nullable();
$table->timestamps(); $table->date('data_adesione')->nullable();
$table->unique(['gruppo_id', 'individuo_id']); $table->timestamps();
}); $table->unique(['gruppo_id', 'individuo_id']);
});
}
} }
public function down(): void public function down(): void
@@ -8,35 +8,41 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('eventi', function (Blueprint $table) { if (!Schema::hasTable('eventi')) {
$table->id(); Schema::create('eventi', function (Blueprint $table) {
$table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null'); $table->id();
$table->string('nome_evento'); $table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null');
$table->string('tipo_evento')->nullable(); $table->string('nome_evento');
$table->enum('tipo_recorrenza', ['singolo', 'ricorrente'])->default('singolo'); $table->string('tipo_evento')->nullable();
$table->unsignedTinyInteger('giorno_settimana')->nullable(); $table->enum('tipo_recorrenza', ['singolo', 'ricorrente'])->default('singolo');
$table->time('ora_inizio')->nullable(); $table->unsignedTinyInteger('giorno_settimana')->nullable();
$table->date('data_specifica')->nullable(); $table->time('ora_inizio')->nullable();
$table->unsignedInteger('durata_minuti')->nullable(); $table->date('data_specifica')->nullable();
$table->text('descrizione')->nullable(); $table->unsignedInteger('durata_minuti')->nullable();
$table->text('note')->nullable(); $table->text('descrizione')->nullable();
$table->timestamps(); $table->text('note')->nullable();
$table->index('tenant_id'); $table->timestamps();
}); $table->index('tenant_id');
});
}
Schema::create('eventi_gruppi', function (Blueprint $table) { if (!Schema::hasTable('eventi_gruppi')) {
$table->id(); Schema::create('eventi_gruppi', function (Blueprint $table) {
$table->foreignId('evento_id')->constrained('eventi')->onDelete('cascade'); $table->id();
$table->foreignId('gruppo_id')->constrained('gruppi')->onDelete('cascade'); $table->foreignId('evento_id')->constrained('eventi')->onDelete('cascade');
$table->timestamps(); $table->foreignId('gruppo_id')->constrained('gruppi')->onDelete('cascade');
}); $table->timestamps();
});
}
Schema::create('eventi_responsabili', function (Blueprint $table) { if (!Schema::hasTable('eventi_responsabili')) {
$table->id(); Schema::create('eventi_responsabili', function (Blueprint $table) {
$table->foreignId('evento_id')->constrained('eventi')->onDelete('cascade'); $table->id();
$table->foreignId('individuo_id')->constrained('individui')->onDelete('cascade'); $table->foreignId('evento_id')->constrained('eventi')->onDelete('cascade');
$table->timestamps(); $table->foreignId('individuo_id')->constrained('individui')->onDelete('cascade');
}); $table->timestamps();
});
}
} }
public function down(): void public function down(): void
@@ -8,22 +8,24 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('documenti', function (Blueprint $table) { if (!Schema::hasTable('documenti')) {
$table->id(); Schema::create('documenti', function (Blueprint $table) {
$table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null'); $table->id();
$table->string('nome_file'); $table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null');
$table->string('file_path'); $table->string('nome_file');
$table->string('tipo')->nullable(); $table->string('file_path');
$table->enum('tipologia', ['avatar', 'galleria', 'documento', 'statuto', 'altro'])->default('documento'); $table->string('tipo')->nullable();
$table->enum('visibilita', ['pubblico', 'gruppo', 'individuo', 'associazione', 'federazione'])->default('gruppo'); $table->enum('tipologia', ['avatar', 'galleria', 'documento', 'statuto', 'altro'])->default('documento');
$table->unsignedBigInteger('visibilita_target_id')->nullable(); $table->enum('visibilita', ['pubblico', 'gruppo', 'individuo', 'associazione', 'federazione'])->default('gruppo');
$table->string('visibilita_target_type')->nullable(); $table->unsignedBigInteger('visibilita_target_id')->nullable();
$table->string('mime_type')->nullable(); $table->string('visibilita_target_type')->nullable();
$table->unsignedBigInteger('dimensione')->nullable(); $table->string('mime_type')->nullable();
$table->text('note')->nullable(); $table->unsignedBigInteger('dimensione')->nullable();
$table->timestamps(); $table->text('note')->nullable();
$table->index('tenant_id'); $table->timestamps();
}); $table->index('tenant_id');
});
}
} }
public function down(): void public function down(): void
@@ -8,43 +8,49 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('mailing_lists', function (Blueprint $table) { if (!Schema::hasTable('mailing_lists')) {
$table->id(); Schema::create('mailing_lists', function (Blueprint $table) {
$table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null'); $table->id();
$table->string('nome'); $table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null');
$table->text('descrizione')->nullable(); $table->string('nome');
$table->boolean('attiva')->default(true); $table->text('descrizione')->nullable();
$table->timestamps(); $table->boolean('attiva')->default(true);
$table->index('tenant_id'); $table->timestamps();
}); $table->index('tenant_id');
});
}
Schema::create('mailing_contacts', function (Blueprint $table) { if (!Schema::hasTable('mailing_contacts')) {
$table->id(); Schema::create('mailing_contacts', function (Blueprint $table) {
$table->foreignId('mailing_list_id')->constrained('mailing_lists')->onDelete('cascade'); $table->id();
$table->foreignId('individuo_id')->constrained('individui')->onDelete('cascade'); $table->foreignId('mailing_list_id')->constrained('mailing_lists')->onDelete('cascade');
$table->boolean('opt_in')->default(true); $table->foreignId('individuo_id')->constrained('individui')->onDelete('cascade');
$table->dateTime('opt_in_data')->nullable(); $table->boolean('opt_in')->default(true);
$table->dateTime('opt_out_data')->nullable(); $table->dateTime('opt_in_data')->nullable();
$table->timestamps(); $table->dateTime('opt_out_data')->nullable();
$table->unique(['mailing_list_id', 'individuo_id']); $table->timestamps();
}); $table->unique(['mailing_list_id', 'individuo_id']);
});
}
Schema::create('mailing_messaggi', function (Blueprint $table) { if (!Schema::hasTable('mailing_messaggi')) {
$table->id(); Schema::create('mailing_messaggi', function (Blueprint $table) {
$table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null'); $table->id();
$table->foreignId('mailing_list_id')->nullable()->constrained('mailing_lists')->onDelete('set null'); $table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null');
$table->unsignedBigInteger('user_id')->nullable(); $table->foreignId('mailing_list_id')->nullable()->constrained('mailing_lists')->onDelete('set null');
$table->string('oggetto'); $table->unsignedBigInteger('user_id')->nullable();
$table->text('corpo')->nullable(); $table->string('oggetto');
$table->enum('canale', ['email', 'telegram'])->default('email'); $table->text('corpo')->nullable();
$table->enum('stato', ['bozza', 'in_coda', 'inviato', 'fallito'])->default('bozza'); $table->enum('canale', ['email', 'telegram'])->default('email');
$table->timestamp('inviato_al')->nullable(); $table->enum('stato', ['bozza', 'in_coda', 'inviato', 'fallito'])->default('bozza');
$table->integer('totale_destinatari')->default(0); $table->timestamp('inviato_al')->nullable();
$table->integer('invii_ok')->default(0); $table->integer('totale_destinatari')->default(0);
$table->integer('invii_falliti')->default(0); $table->integer('invii_ok')->default(0);
$table->timestamps(); $table->integer('invii_falliti')->default(0);
$table->index('tenant_id'); $table->timestamps();
}); $table->index('tenant_id');
});
}
} }
public function down(): void public function down(): void
@@ -8,18 +8,20 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('notifiche', function (Blueprint $table) { if (!Schema::hasTable('notifiche')) {
$table->id(); Schema::create('notifiche', function (Blueprint $table) {
$table->unsignedBigInteger('user_id')->nullable(); $table->id();
$table->string('tipo'); $table->unsignedBigInteger('user_id')->nullable();
$table->string('titolo'); $table->string('tipo');
$table->text('messaggio'); $table->string('titolo');
$table->string('link')->nullable(); $table->text('messaggio');
$table->boolean('is_read')->default(false); $table->string('link')->nullable();
$table->timestamp('read_at')->nullable(); $table->boolean('is_read')->default(false);
$table->timestamps(); $table->timestamp('read_at')->nullable();
$table->index('user_id'); $table->timestamps();
}); $table->index('user_id');
});
}
} }
public function down(): void public function down(): void
@@ -8,34 +8,40 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('users', function (Blueprint $table) { if (!Schema::hasTable('users')) {
$table->id(); Schema::create('users', function (Blueprint $table) {
$table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null'); $table->id();
$table->string('name'); $table->foreignId('tenant_id')->nullable()->constrained('tenants')->onDelete('set null');
$table->string('email')->unique(); $table->string('name');
$table->timestamp('email_verified_at')->nullable(); $table->string('email')->unique();
$table->string('password'); $table->timestamp('email_verified_at')->nullable();
$table->boolean('is_admin')->default(false); $table->string('password');
$table->rememberToken(); $table->boolean('is_admin')->default(false);
$table->timestamps(); $table->rememberToken();
$table->index('tenant_id'); $table->timestamps();
$table->index('email'); $table->index('tenant_id');
}); $table->index('email');
});
}
Schema::create('password_reset_tokens', function (Blueprint $table) { if (!Schema::hasTable('password_reset_tokens')) {
$table->string('email')->primary(); Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('token'); $table->string('email')->primary();
$table->timestamp('created_at')->nullable(); $table->string('token');
}); $table->timestamp('created_at')->nullable();
});
}
Schema::create('sessions', function (Blueprint $table) { if (!Schema::hasTable('sessions')) {
$table->string('id')->primary(); Schema::create('sessions', function (Blueprint $table) {
$table->foreignId('user_id')->nullable()->index(); $table->string('id')->primary();
$table->string('ip_address', 45)->nullable(); $table->foreignId('user_id')->nullable()->index();
$table->text('user_agent')->nullable(); $table->string('ip_address', 45)->nullable();
$table->longText('payload'); $table->text('user_agent')->nullable();
$table->integer('last_activity')->index(); $table->longText('payload');
}); $table->integer('last_activity')->index();
});
}
} }
public function down(): void public function down(): void
@@ -8,50 +8,60 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('cache', function (Blueprint $table) { if (!Schema::hasTable('cache')) {
$table->string('key')->primary(); Schema::create('cache', function (Blueprint $table) {
$table->mediumText('value'); $table->string('key')->primary();
$table->integer('expiration'); $table->mediumText('value');
}); $table->integer('expiration');
});
}
Schema::create('cache_locks', function (Blueprint $table) { if (!Schema::hasTable('cache_locks')) {
$table->string('key')->primary(); Schema::create('cache_locks', function (Blueprint $table) {
$table->string('owner'); $table->string('key')->primary();
$table->integer('expiration'); $table->string('owner');
}); $table->integer('expiration');
});
}
Schema::create('jobs', function (Blueprint $table) { if (!Schema::hasTable('jobs')) {
$table->id(); Schema::create('jobs', function (Blueprint $table) {
$table->string('queue')->index(); $table->id();
$table->longText('payload'); $table->string('queue')->index();
$table->unsignedTinyInteger('attempts'); $table->longText('payload');
$table->unsignedInteger('reserved_at')->nullable(); $table->unsignedTinyInteger('attempts');
$table->unsignedInteger('available_at'); $table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('created_at'); $table->unsignedInteger('available_at');
}); $table->unsignedInteger('created_at');
});
}
Schema::create('job_batches', function (Blueprint $table) { if (!Schema::hasTable('job_batches')) {
$table->string('id')->primary(); Schema::create('job_batches', function (Blueprint $table) {
$table->string('name'); $table->string('id')->primary();
$table->integer('total_jobs'); $table->string('name');
$table->integer('pending_jobs'); $table->integer('total_jobs');
$table->integer('failed_jobs'); $table->integer('pending_jobs');
$table->longText('failed_job_ids'); $table->integer('failed_jobs');
$table->mediumText('options')->nullable(); $table->longText('failed_job_ids');
$table->integer('cancelled_at')->nullable(); $table->mediumText('options')->nullable();
$table->integer('created_at'); $table->integer('cancelled_at')->nullable();
$table->integer('finished_at')->nullable(); $table->integer('created_at');
}); $table->integer('finished_at')->nullable();
});
}
Schema::create('failed_jobs', function (Blueprint $table) { if (!Schema::hasTable('failed_jobs')) {
$table->id(); Schema::create('failed_jobs', function (Blueprint $table) {
$table->string('uuid')->unique(); $table->id();
$table->text('connection'); $table->string('uuid')->unique();
$table->text('queue'); $table->text('connection');
$table->longText('payload'); $table->text('queue');
$table->longText('exception'); $table->longText('payload');
$table->timestamp('failed_at'); $table->longText('exception');
}); $table->timestamp('failed_at');
});
}
} }
public function down(): void public function down(): void
@@ -8,12 +8,14 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('eventi_documenti', function (Blueprint $table) { if (!Schema::hasTable('eventi_documenti')) {
$table->id(); Schema::create('eventi_documenti', function (Blueprint $table) {
$table->foreignId('evento_id')->constrained('eventi')->onDelete('cascade'); $table->id();
$table->foreignId('documento_id')->constrained('documenti')->onDelete('cascade'); $table->foreignId('evento_id')->constrained('eventi')->onDelete('cascade');
$table->timestamps(); $table->foreignId('documento_id')->constrained('documenti')->onDelete('cascade');
}); $table->timestamps();
});
}
} }
public function down(): void public function down(): void
@@ -8,19 +8,21 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('viste_report', function (Blueprint $table) { if (!Schema::hasTable('viste_report')) {
$table->id(); Schema::create('viste_report', function (Blueprint $table) {
$table->foreignId('user_id')->constrained('users')->onDelete('cascade'); $table->id();
$table->string('nome'); $table->foreignId('user_id')->constrained('users')->onDelete('cascade');
$table->string('tipo'); // individui, gruppi, documenti, eventi $table->string('nome');
$table->json('colonne_visibili')->nullable(); $table->string('tipo'); // individui, gruppi, documenti, eventi
$table->json('colonne_ordinamento')->nullable(); // [['colonna', 'direzione']] $table->json('colonne_visibili')->nullable();
$table->json('filtri')->nullable(); // [['colonna', 'operatore', 'valore']] $table->json('colonne_ordinamento')->nullable(); // [['colonna', 'direzione']]
$table->string('ricerca')->nullable(); $table->json('filtri')->nullable(); // [['colonna', 'operatore', 'valore']]
$table->timestamps(); $table->string('ricerca')->nullable();
$table->index('tipo'); $table->timestamps();
$table->index('user_id'); $table->index('tipo');
}); $table->index('user_id');
});
}
} }
public function down(): void public function down(): void
@@ -8,14 +8,16 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('tipologie_documenti', function (Blueprint $table) { if (!Schema::hasTable('tipologie_documenti')) {
$table->id(); Schema::create('tipologie_documenti', function (Blueprint $table) {
$table->string('nome', 50)->unique(); $table->id();
$table->string('descrizione', 255)->nullable(); $table->string('nome', 50)->unique();
$table->integer('ordine')->default(0); $table->string('descrizione', 255)->nullable();
$table->boolean('attiva')->default(true); $table->integer('ordine')->default(0);
$table->timestamps(); $table->boolean('attiva')->default(true);
}); $table->timestamps();
});
}
$defaultTipologie = ['avatar', 'galleria', 'documento', 'statuto', 'altro']; $defaultTipologie = ['avatar', 'galleria', 'documento', 'statuto', 'altro'];
foreach ($defaultTipologie as $i => $nome) { foreach ($defaultTipologie as $i => $nome) {
@@ -14,28 +14,32 @@ return new class extends Migration
}); });
} }
Schema::create('activity_logs', function (Blueprint $table) { if (!Schema::hasTable('activity_logs')) {
$table->id(); Schema::create('activity_logs', function (Blueprint $table) {
$table->foreignId('user_id')->constrained()->onDelete('cascade'); $table->id();
$table->string('action'); $table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->string('module'); $table->string('action');
$table->string('description')->nullable(); $table->string('module');
$table->json('details')->nullable(); $table->string('description')->nullable();
$table->string('ip_address', 45)->nullable(); $table->json('details')->nullable();
$table->timestamp('created_at')->useCurrent(); $table->string('ip_address', 45)->nullable();
$table->timestamp('created_at')->useCurrent();
$table->index(['user_id', 'module']);
$table->index(['created_at']);
$table->index(['action']);
});
}
$table->index(['user_id', 'module']); if (!Schema::hasTable('role_presets')) {
$table->index(['created_at']); Schema::create('role_presets', function (Blueprint $table) {
$table->index(['action']); $table->id();
}); $table->string('name', 50)->unique();
$table->string('description')->nullable();
Schema::create('role_presets', function (Blueprint $table) { $table->json('permissions');
$table->id(); $table->timestamps();
$table->string('name', 50)->unique(); });
$table->string('description')->nullable(); }
$table->json('permissions');
$table->timestamps();
});
} }
public function down(): void public function down(): void
@@ -23,96 +23,106 @@ return new class extends Migration
/** /**
* See `docs/prerequisites.md` for suggested lengths on 'name' and 'guard_name' if "1071 Specified key was too long" errors are encountered. * See `docs/prerequisites.md` for suggested lengths on 'name' and 'guard_name' if "1071 Specified key was too long" errors are encountered.
*/ */
Schema::create($tableNames['permissions'], static function (Blueprint $table) { if (!Schema::hasTable($tableNames['permissions'])) {
$table->id(); // permission id Schema::create($tableNames['permissions'], static function (Blueprint $table) {
$table->string('name'); $table->id(); // permission id
$table->string('guard_name'); $table->string('name');
$table->timestamps(); $table->string('guard_name');
$table->timestamps();
$table->unique(['name', 'guard_name']);
}); $table->unique(['name', 'guard_name']);
});
}
/** /**
* See `docs/prerequisites.md` for suggested lengths on 'name' and 'guard_name' if "1071 Specified key was too long" errors are encountered. * See `docs/prerequisites.md` for suggested lengths on 'name' and 'guard_name' if "1071 Specified key was too long" errors are encountered.
*/ */
Schema::create($tableNames['roles'], static function (Blueprint $table) use ($teams, $columnNames) { if (!Schema::hasTable($tableNames['roles'])) {
$table->id(); // role id Schema::create($tableNames['roles'], static function (Blueprint $table) use ($teams, $columnNames) {
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing $table->id(); // role id
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable(); $table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index'); $table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
} }
$table->string('name'); $table->string('name');
$table->string('guard_name'); $table->string('guard_name');
$table->timestamps(); $table->timestamps();
if ($teams || config('permission.testing')) { if ($teams || config('permission.testing')) {
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']); $table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
} else { } else {
$table->unique(['name', 'guard_name']); $table->unique(['name', 'guard_name']);
} }
}); });
}
Schema::create($tableNames['model_has_permissions'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) { if (!Schema::hasTable($tableNames['model_has_permissions'])) {
$table->unsignedBigInteger($pivotPermission); Schema::create($tableNames['model_has_permissions'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) {
$table->unsignedBigInteger($pivotPermission);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']); $table->string('model_type');
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index'); $table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
$table->foreign($pivotPermission)
$table->foreign($pivotPermission)
->references('id') // permission id ->references('id') // permission id
->on($tableNames['permissions']) ->on($tableNames['permissions'])
->cascadeOnDelete(); ->cascadeOnDelete();
if ($teams) { if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']); $table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index'); $table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'], $table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary'); 'model_has_permissions_permission_model_type_primary');
} else { } else {
$table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'], $table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary'); 'model_has_permissions_permission_model_type_primary');
} }
}); });
}
Schema::create($tableNames['model_has_roles'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) { if (!Schema::hasTable($tableNames['model_has_roles'])) {
$table->unsignedBigInteger($pivotRole); Schema::create($tableNames['model_has_roles'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) {
$table->unsignedBigInteger($pivotRole);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']); $table->string('model_type');
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index'); $table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
$table->foreign($pivotRole)
$table->foreign($pivotRole)
->references('id') // role id ->references('id') // role id
->on($tableNames['roles']) ->on($tableNames['roles'])
->cascadeOnDelete(); ->cascadeOnDelete();
if ($teams) { if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']); $table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index'); $table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'], $table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary'); 'model_has_roles_role_model_type_primary');
} else { } else {
$table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'], $table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary'); 'model_has_roles_role_model_type_primary');
} }
}); });
}
Schema::create($tableNames['role_has_permissions'], static function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) { if (!Schema::hasTable($tableNames['role_has_permissions'])) {
$table->unsignedBigInteger($pivotPermission); Schema::create($tableNames['role_has_permissions'], static function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) {
$table->unsignedBigInteger($pivotRole); $table->unsignedBigInteger($pivotPermission);
$table->unsignedBigInteger($pivotRole);
$table->foreign($pivotPermission)
$table->foreign($pivotPermission)
->references('id') // permission id ->references('id') // permission id
->on($tableNames['permissions']) ->on($tableNames['permissions'])
->cascadeOnDelete(); ->cascadeOnDelete();
$table->foreign($pivotRole) $table->foreign($pivotRole)
->references('id') // role id ->references('id') // role id
->on($tableNames['roles']) ->on($tableNames['roles'])
->cascadeOnDelete(); ->cascadeOnDelete();
$table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary'); $table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary');
}); });
}
app('cache') app('cache')
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null) ->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
@@ -8,26 +8,28 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('email_settings', function (Blueprint $table) { if (!Schema::hasTable('email_settings')) {
$table->id(); Schema::create('email_settings', function (Blueprint $table) {
$table->string('imap_host')->nullable(); $table->id();
$table->integer('imap_port')->nullable()->default(993); $table->string('imap_host')->nullable();
$table->string('imap_encryption')->nullable()->default('ssl'); $table->integer('imap_port')->nullable()->default(993);
$table->string('imap_username')->nullable(); $table->string('imap_encryption')->nullable()->default('ssl');
$table->string('imap_password')->nullable(); $table->string('imap_username')->nullable();
$table->string('smtp_host')->nullable(); $table->string('imap_password')->nullable();
$table->integer('smtp_port')->nullable()->default(587); $table->string('smtp_host')->nullable();
$table->string('smtp_encryption')->nullable()->default('tls'); $table->integer('smtp_port')->nullable()->default(587);
$table->string('smtp_username')->nullable(); $table->string('smtp_encryption')->nullable()->default('tls');
$table->string('smtp_password')->nullable(); $table->string('smtp_username')->nullable();
$table->string('email_address')->nullable(); $table->string('smtp_password')->nullable();
$table->string('email_name')->nullable(); $table->string('email_address')->nullable();
$table->string('reply_to')->nullable(); $table->string('email_name')->nullable();
$table->integer('sync_interval_minutes')->default(5); $table->string('reply_to')->nullable();
$table->timestamp('last_sync_at')->nullable(); $table->integer('sync_interval_minutes')->default(5);
$table->boolean('is_active')->default(false); $table->timestamp('last_sync_at')->nullable();
$table->timestamps(); $table->boolean('is_active')->default(false);
}); $table->timestamps();
});
}
} }
public function down(): void public function down(): void
@@ -8,17 +8,19 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('email_folders', function (Blueprint $table) { if (!Schema::hasTable('email_folders')) {
$table->id(); Schema::create('email_folders', function (Blueprint $table) {
$table->string('name'); $table->id();
$table->string('imap_folder_name')->nullable(); $table->string('name');
$table->string('type')->default('custom'); $table->string('imap_folder_name')->nullable();
$table->string('icon')->default('fa-folder'); $table->string('type')->default('custom');
$table->string('color')->nullable(); $table->string('icon')->default('fa-folder');
$table->integer('sort_order')->default(0); $table->string('color')->nullable();
$table->boolean('is_system')->default(false); $table->integer('sort_order')->default(0);
$table->timestamps(); $table->boolean('is_system')->default(false);
}); $table->timestamps();
});
}
} }
public function down(): void public function down(): void
@@ -8,35 +8,37 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('email_messages', function (Blueprint $table) { if (!Schema::hasTable('email_messages')) {
$table->id(); Schema::create('email_messages', function (Blueprint $table) {
$table->foreignId('email_folder_id')->constrained('email_folders')->onDelete('cascade'); $table->id();
$table->string('message_id')->nullable()->index(); $table->foreignId('email_folder_id')->constrained('email_folders')->onDelete('cascade');
$table->string('subject')->nullable(); $table->string('message_id')->nullable()->index();
$table->string('from_name')->nullable(); $table->string('subject')->nullable();
$table->string('from_email')->nullable(); $table->string('from_name')->nullable();
$table->string('to_name')->nullable(); $table->string('from_email')->nullable();
$table->string('to_email')->nullable(); $table->string('to_name')->nullable();
$table->text('cc')->nullable(); $table->string('to_email')->nullable();
$table->text('bcc')->nullable(); $table->text('cc')->nullable();
$table->longText('body_text')->nullable(); $table->text('bcc')->nullable();
$table->longText('body_html')->nullable(); $table->longText('body_text')->nullable();
$table->boolean('is_read')->default(false); $table->longText('body_html')->nullable();
$table->boolean('is_starred')->default(false); $table->boolean('is_read')->default(false);
$table->boolean('is_important')->default(false); $table->boolean('is_starred')->default(false);
$table->boolean('is_sent')->default(false); $table->boolean('is_important')->default(false);
$table->boolean('is_draft')->default(false); $table->boolean('is_sent')->default(false);
$table->boolean('is_trash')->default(false); $table->boolean('is_draft')->default(false);
$table->timestamp('received_at')->nullable(); $table->boolean('is_trash')->default(false);
$table->timestamp('sent_at')->nullable(); $table->timestamp('received_at')->nullable();
$table->unsignedBigInteger('imap_uid')->nullable(); $table->timestamp('sent_at')->nullable();
$table->timestamps(); $table->unsignedBigInteger('imap_uid')->nullable();
$table->timestamps();
$table->index('is_read');
$table->index('is_starred'); $table->index('is_read');
$table->index('is_sent'); $table->index('is_starred');
$table->index('received_at'); $table->index('is_sent');
}); $table->index('received_at');
});
}
} }
public function down(): void public function down(): void
@@ -8,17 +8,19 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('email_attachments', function (Blueprint $table) { if (!Schema::hasTable('email_attachments')) {
$table->id(); Schema::create('email_attachments', function (Blueprint $table) {
$table->foreignId('email_message_id')->constrained('email_messages')->onDelete('cascade'); $table->id();
$table->string('filename'); $table->foreignId('email_message_id')->constrained('email_messages')->onDelete('cascade');
$table->string('mime_type')->nullable(); $table->string('filename');
$table->bigInteger('size')->default(0); $table->string('mime_type')->nullable();
$table->string('file_path'); $table->bigInteger('size')->default(0);
$table->boolean('is_saved_to_documenti')->default(false); $table->string('file_path');
$table->foreignId('documenti_id')->nullable()->constrained('documenti')->onDelete('set null'); $table->boolean('is_saved_to_documenti')->default(false);
$table->timestamps(); $table->foreignId('documenti_id')->nullable()->constrained('documenti')->onDelete('set null');
}); $table->timestamps();
});
}
} }
public function down(): void public function down(): void
@@ -8,14 +8,16 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('ruoli', function (Blueprint $table) { if (!Schema::hasTable('ruoli')) {
$table->id(); Schema::create('ruoli', function (Blueprint $table) {
$table->string('nome', 50)->unique(); $table->id();
$table->string('descrizione', 255)->nullable(); $table->string('nome', 50)->unique();
$table->integer('ordine')->default(0); $table->string('descrizione', 255)->nullable();
$table->boolean('attiva')->default(true); $table->integer('ordine')->default(0);
$table->timestamps(); $table->boolean('attiva')->default(true);
}); $table->timestamps();
});
}
$defaultRuoli = [ $defaultRuoli = [
['nome' => 'Membro', 'descrizione' => 'Membro del gruppo'], ['nome' => 'Membro', 'descrizione' => 'Membro del gruppo'],
@@ -8,15 +8,17 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('report_custom', function (Blueprint $table) { if (!Schema::hasTable('report_custom')) {
$table->id(); Schema::create('report_custom', function (Blueprint $table) {
$table->foreignId('user_id')->constrained('users')->onDelete('cascade'); $table->id();
$table->string('nome'); $table->foreignId('user_id')->constrained('users')->onDelete('cascade');
$table->text('descrizione')->nullable(); $table->string('nome');
$table->string('tipo_report'); $table->text('descrizione')->nullable();
$table->json('config')->nullable(); $table->string('tipo_report');
$table->timestamps(); $table->json('config')->nullable();
}); $table->timestamps();
});
}
} }
public function down(): void public function down(): void
@@ -10,14 +10,16 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('tipologie_eventi', function (Blueprint $table) { if (!Schema::hasTable('tipologie_eventi')) {
$table->id(); Schema::create('tipologie_eventi', function (Blueprint $table) {
$table->string('nome', 50)->unique(); $table->id();
$table->string('descrizione', 255)->nullable(); $table->string('nome', 50)->unique();
$table->integer('ordine')->default(0); $table->string('descrizione', 255)->nullable();
$table->boolean('attiva')->default(true); $table->integer('ordine')->default(0);
$table->timestamps(); $table->boolean('attiva')->default(true);
}); $table->timestamps();
});
}
DB::table('tipologie_eventi')->insert([ DB::table('tipologie_eventi')->insert([
['nome' => 'catechesi', 'descrizione' => 'Catechesi', 'ordine' => 0, 'attiva' => true], ['nome' => 'catechesi', 'descrizione' => 'Catechesi', 'ordine' => 0, 'attiva' => true],
@@ -10,21 +10,23 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('sender_accounts', function (Blueprint $table) { if (!Schema::hasTable('sender_accounts')) {
$table->id(); Schema::create('sender_accounts', function (Blueprint $table) {
$table->string('email_address')->unique(); $table->id();
$table->string('email_name')->nullable(); $table->string('email_address')->unique();
$table->string('smtp_host')->nullable(); $table->string('email_name')->nullable();
$table->integer('smtp_port')->default(587); $table->string('smtp_host')->nullable();
$table->string('smtp_encryption')->default('tls'); $table->integer('smtp_port')->default(587);
$table->string('smtp_username')->nullable(); $table->string('smtp_encryption')->default('tls');
$table->text('smtp_password')->nullable(); $table->string('smtp_username')->nullable();
$table->string('reply_to')->nullable(); $table->text('smtp_password')->nullable();
$table->string('verify_email')->nullable(); $table->string('reply_to')->nullable();
$table->text('note')->nullable(); $table->string('verify_email')->nullable();
$table->boolean('is_active')->default(true); $table->text('note')->nullable();
$table->timestamps(); $table->boolean('is_active')->default(true);
}); $table->timestamps();
});
}
} }
public function down(): void public function down(): void
@@ -8,12 +8,14 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('documenti_cartelle', function (Blueprint $table) { if (!Schema::hasTable('documenti_cartelle')) {
$table->id(); Schema::create('documenti_cartelle', function (Blueprint $table) {
$table->foreignId('parent_id')->nullable()->constrained('documenti_cartelle')->onDelete('cascade'); $table->id();
$table->string('nome'); $table->foreignId('parent_id')->nullable()->constrained('documenti_cartelle')->onDelete('cascade');
$table->timestamps(); $table->string('nome');
}); $table->timestamps();
});
}
} }
public function down(): void public function down(): void
@@ -8,15 +8,17 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('storage_repositories', function (Blueprint $table) { if (!Schema::hasTable('storage_repositories')) {
$table->id(); Schema::create('storage_repositories', function (Blueprint $table) {
$table->string('nome'); $table->id();
$table->string('tipo', 50); $table->string('nome');
$table->text('config'); $table->string('tipo', 50);
$table->boolean('is_active')->default(true); $table->text('config');
$table->integer('ordine')->default(0); $table->boolean('is_active')->default(true);
$table->timestamps(); $table->integer('ordine')->default(0);
}); $table->timestamps();
});
}
} }
public function down(): void public function down(): void
@@ -10,21 +10,23 @@ return new class extends Migration
{ {
public function up(): void public function up(): void
{ {
Schema::create('calendario_connessioni', function (Blueprint $table) { if (!Schema::hasTable('calendario_connessioni')) {
$table->id(); Schema::create('calendario_connessioni', function (Blueprint $table) {
$table->string('nome'); $table->id();
$table->string('tipo'); // google_calendar, caldav $table->string('nome');
$table->text('config'); // JSON $table->string('tipo'); // google_calendar, caldav
$table->string('stato')->default('disconnesso'); // connesso, disconnesso, errore $table->text('config'); // JSON
$table->string('sync_direction')->default('bidirectional'); // import, export, bidirectional $table->string('stato')->default('disconnesso'); // connesso, disconnesso, errore
$table->integer('sync_interval_minutes')->default(60); $table->string('sync_direction')->default('bidirectional'); // import, export, bidirectional
$table->timestamp('last_sync_at')->nullable(); $table->integer('sync_interval_minutes')->default(60);
$table->timestamp('last_error_at')->nullable(); $table->timestamp('last_sync_at')->nullable();
$table->text('last_error_message')->nullable(); $table->timestamp('last_error_at')->nullable();
$table->boolean('is_active')->default(true); $table->text('last_error_message')->nullable();
$table->integer('ordine')->default(0); $table->boolean('is_active')->default(true);
$table->timestamps(); $table->integer('ordine')->default(0);
}); $table->timestamps();
});
}
} }
public function down(): void public function down(): void
@@ -18,7 +18,7 @@ return new class extends Migration
$table->string('color', 7)->nullable(); $table->string('color', 7)->nullable();
$table->integer('order_column')->default(0); $table->integer('order_column')->default(0);
$table->timestamps(); $table->timestamps();
}); });
} }
if (!Schema::hasTable('taggables')) { if (!Schema::hasTable('taggables')) {
@@ -26,7 +26,7 @@ return new class extends Migration
$table->foreignId('tag_id')->constrained()->cascadeOnDelete(); $table->foreignId('tag_id')->constrained()->cascadeOnDelete();
$table->morphs('taggable'); $table->morphs('taggable');
$table->primary(['tag_id', 'taggable_id', 'taggable_type']); $table->primary(['tag_id', 'taggable_id', 'taggable_type']);
}); });
} }
} }
+1 -1
View File
@@ -68,7 +68,7 @@ class ComuniSeeder extends Seeder
]; ];
foreach ($comuni as $c) { foreach ($comuni as $c) {
Comune::create($c); Comune::firstOrCreate(['codice_istat' => $c['codice_istat']], $c);
} }
} }
} }
+21 -17
View File
@@ -20,23 +20,27 @@ class DatabaseSeeder extends Seeder
DockerBaseDataSeeder::class, DockerBaseDataSeeder::class,
]); ]);
$admin = User::create([ $admin = User::firstOrCreate(
'name' => 'Admin', ['email' => 'admin@glastree.local'],
'email' => 'admin@glastree.local', [
'password' => bcrypt('password'), 'name' => 'Admin',
'is_admin' => true, 'password' => bcrypt('password'),
'status' => 'active', 'is_admin' => true,
'permissions' => [ 'status' => 'active',
'individui' => 2, 'permissions' => [
'gruppi' => 2, 'individui' => 2,
'eventi' => 2, 'gruppi' => 2,
'documenti' => 2, 'eventi' => 2,
'mailing' => 2, 'documenti' => 2,
'viste' => 2, 'mailing' => 2,
], 'viste' => 2,
]); ],
]
);
$admin->role_preset_id = 1; if (!$admin->role_preset_id) {
$admin->save(); $admin->role_preset_id = 1;
$admin->save();
}
} }
} }
+1 -1
View File
@@ -149,7 +149,7 @@ class DiocesiSeeder extends Seeder
]; ];
foreach ($diocesi as $d) { foreach ($diocesi as $d) {
Diocesi::create($d); Diocesi::firstOrCreate(['nome' => $d['nome']], $d);
} }
} }
} }