1.0.4 - fix instal.php

This commit is contained in:
2026-06-03 11:18:20 +02:00
parent 7381d86362
commit 25168debc0
7 changed files with 164 additions and 105 deletions
@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
if (Schema::hasTable('app_settings')) {
return;
}
Schema::create('app_settings', function (Blueprint $table) {
$table->id();
$table->string('nome_applicazione')->nullable();
$table->string('nome_organizzazione')->nullable();
$table->string('logo')->nullable();
$table->string('logo_small')->nullable();
$table->string('logo_path')->nullable();
$table->string('logo_small_path')->nullable();
$table->string('footer_text')->nullable();
$table->string('app_version')->nullable();
$table->string('dashboard_welcome')->nullable();
$table->boolean('show_version')->default(false);
$table->string('documenti_storage_disk')->default('local');
$table->string('documenti_storage_path')->default('documenti');
$table->string('backup_path')->default('backups');
$table->integer('backup_retention_days')->default(30);
$table->boolean('backup_include_files')->default(true);
$table->boolean('backup_include_env')->default(true);
$table->boolean('backup_auto_enabled')->default(false);
$table->string('backup_auto_frequency', 20)->default('daily');
$table->integer('backup_auto_hour')->default(3);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('app_settings');
}
};
@@ -8,10 +8,21 @@ return new class extends Migration
{
public function up(): void
{
Schema::table('app_settings', function (Blueprint $table) {
$table->string('logo_path')->nullable()->after('logo');
$table->string('logo_small_path')->nullable()->after('logo_small');
});
if (!Schema::hasTable('app_settings')) {
return;
}
if (!Schema::hasColumn('app_settings', 'logo_path')) {
Schema::table('app_settings', function (Blueprint $table) {
$table->string('logo_path')->nullable()->after('logo');
});
}
if (!Schema::hasColumn('app_settings', 'logo_small_path')) {
Schema::table('app_settings', function (Blueprint $table) {
$table->string('logo_small_path')->nullable()->after('logo_small');
});
}
}
public function down(): void
@@ -8,12 +8,24 @@ return new class extends Migration
{
public function up(): void
{
Schema::table('app_settings', function (Blueprint $table) {
$table->string('footer_text')->nullable()->after('nome_organizzazione');
$table->string('app_version')->nullable()->after('footer_text');
$table->string('dashboard_welcome')->nullable()->after('app_version');
$table->boolean('show_version')->default(false)->after('dashboard_welcome');
});
if (!Schema::hasTable('app_settings')) {
return;
}
$columns = ['footer_text', 'app_version', 'dashboard_welcome', 'show_version'];
foreach ($columns as $column) {
if (!Schema::hasColumn('app_settings', $column)) {
Schema::table('app_settings', function (Blueprint $table) use ($column) {
match ($column) {
'footer_text' => $table->string('footer_text')->nullable()->after('nome_organizzazione'),
'app_version' => $table->string('app_version')->nullable()->after('footer_text'),
'dashboard_welcome' => $table->string('dashboard_welcome')->nullable()->after('app_version'),
'show_version' => $table->boolean('show_version')->default(false)->after('dashboard_welcome'),
};
});
}
}
}
public function down(): void
@@ -8,10 +8,21 @@ return new class extends Migration
{
public function up(): void
{
Schema::table('app_settings', function (Blueprint $table) {
$table->string('documenti_storage_disk')->default('local')->after('show_version');
$table->string('documenti_storage_path')->default('documenti')->after('documenti_storage_disk');
});
if (!Schema::hasTable('app_settings')) {
return;
}
if (!Schema::hasColumn('app_settings', 'documenti_storage_disk')) {
Schema::table('app_settings', function (Blueprint $table) {
$table->string('documenti_storage_disk')->default('local')->after('show_version');
});
}
if (!Schema::hasColumn('app_settings', 'documenti_storage_path')) {
Schema::table('app_settings', function (Blueprint $table) {
$table->string('documenti_storage_path')->default('documenti')->after('documenti_storage_disk');
});
}
}
public function down(): void
@@ -10,15 +10,31 @@ return new class extends Migration
{
public function up(): void
{
Schema::table('app_settings', function (Blueprint $table) {
$table->string('backup_path')->default('backups')->after('show_version');
$table->integer('backup_retention_days')->default(30)->after('backup_path');
$table->boolean('backup_include_files')->default(true)->after('backup_retention_days');
$table->boolean('backup_include_env')->default(true)->after('backup_include_files');
$table->boolean('backup_auto_enabled')->default(false)->after('backup_include_env');
$table->string('backup_auto_frequency', 20)->default('daily')->after('backup_auto_enabled');
$table->integer('backup_auto_hour')->default(3)->after('backup_auto_frequency');
});
if (!Schema::hasTable('app_settings')) {
return;
}
$columns = [
'backup_path' => ['type' => 'string', 'default' => 'backups'],
'backup_retention_days' => ['type' => 'integer', 'default' => 30],
'backup_include_files' => ['type' => 'boolean', 'default' => true],
'backup_include_env' => ['type' => 'boolean', 'default' => true],
'backup_auto_enabled' => ['type' => 'boolean', 'default' => false],
'backup_auto_frequency' => ['type' => 'string', 'length' => 20, 'default' => 'daily'],
'backup_auto_hour' => ['type' => 'integer', 'default' => 3],
];
foreach ($columns as $column => $config) {
if (!Schema::hasColumn('app_settings', $column)) {
Schema::table('app_settings', function (Blueprint $table) use ($column, $config) {
match ($config['type']) {
'string' => $table->string($column, $config['length'] ?? 255)->default($config['default'])->after('show_version'),
'integer' => $table->integer($column)->default($config['default'])->after('show_version'),
'boolean' => $table->boolean($column)->default($config['default'])->after('show_version'),
};
});
}
}
}
public function down(): void