diff --git a/app/Actions/Diagnostics/Configuration.php b/app/Actions/Diagnostics/Configuration.php index 2635bd056c3..36886ebff37 100644 --- a/app/Actions/Diagnostics/Configuration.php +++ b/app/Actions/Diagnostics/Configuration.php @@ -4,6 +4,7 @@ use App\Exceptions\Internal\QueryBuilderException; use App\Models\Configs; +use Illuminate\Support\Facades\Schema; class Configuration { @@ -17,6 +18,10 @@ class Configuration */ public function get(): array { + if (!Schema::hasTable('configs')) { + return ['Error: migration has not been run yet.']; + } + // Load settings $settings = Configs::query() ->where('confidentiality', '<=', 2) diff --git a/app/Actions/Diagnostics/Pipes/Checks/AdminUserExistsCheck.php b/app/Actions/Diagnostics/Pipes/Checks/AdminUserExistsCheck.php index 6da4210efa9..4473cab3462 100644 --- a/app/Actions/Diagnostics/Pipes/Checks/AdminUserExistsCheck.php +++ b/app/Actions/Diagnostics/Pipes/Checks/AdminUserExistsCheck.php @@ -4,6 +4,7 @@ use App\Contracts\DiagnosticPipe; use App\Models\User; +use Illuminate\Support\Facades\Schema; class AdminUserExistsCheck implements DiagnosticPipe { @@ -12,6 +13,10 @@ class AdminUserExistsCheck implements DiagnosticPipe */ public function handle(array &$data, \Closure $next): array { + if (!Schema::hasTable('users')) { + return $next($data); + } + $numberOfAdmin = User::query()->where('may_administrate', '=', true)->count(); if ($numberOfAdmin === 0) { $data[] = 'Error: User Admin not found in database. Please run: "php lychee:create_user {username} {password}"'; @@ -19,4 +24,4 @@ public function handle(array &$data, \Closure $next): array return $next($data); } -} \ No newline at end of file +} diff --git a/app/Actions/Diagnostics/Pipes/Checks/ConfigSanityCheck.php b/app/Actions/Diagnostics/Pipes/Checks/ConfigSanityCheck.php index b9bef2147ee..7dfea32d313 100644 --- a/app/Actions/Diagnostics/Pipes/Checks/ConfigSanityCheck.php +++ b/app/Actions/Diagnostics/Pipes/Checks/ConfigSanityCheck.php @@ -4,6 +4,7 @@ use App\Contracts\DiagnosticPipe; use App\Models\Configs; +use Illuminate\Support\Facades\Schema; /** * Small checks on the content of the config database. @@ -18,6 +19,10 @@ class ConfigSanityCheck implements DiagnosticPipe */ public function handle(array &$data, \Closure $next): array { + if (!Schema::hasTable('configs')) { + return $next($data); + } + // Load settings $this->settings = Configs::get(); diff --git a/app/Actions/Diagnostics/Pipes/Checks/DBIntegrityCheck.php b/app/Actions/Diagnostics/Pipes/Checks/DBIntegrityCheck.php index 3871dae507d..2bd2c8dcbd2 100644 --- a/app/Actions/Diagnostics/Pipes/Checks/DBIntegrityCheck.php +++ b/app/Actions/Diagnostics/Pipes/Checks/DBIntegrityCheck.php @@ -5,6 +5,7 @@ use App\Contracts\DiagnosticPipe; use App\Models\Photo; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Schema; /** * This checks the Database integrity. @@ -19,6 +20,10 @@ class DBIntegrityCheck implements DiagnosticPipe */ public function handle(array &$data, \Closure $next): array { + if (!Schema::hasTable('size_variants') || !Schema::hasTable('photos')) { + return $next($data); + } + $subJoin = DB::table('size_variants')->where('size_variants.type', '=', 0); $photos = Photo::query() ->with(['album']) diff --git a/app/Actions/Diagnostics/Pipes/Checks/ImageOptCheck.php b/app/Actions/Diagnostics/Pipes/Checks/ImageOptCheck.php index 031f4bf3bc0..4796260535f 100644 --- a/app/Actions/Diagnostics/Pipes/Checks/ImageOptCheck.php +++ b/app/Actions/Diagnostics/Pipes/Checks/ImageOptCheck.php @@ -5,6 +5,7 @@ use App\Contracts\DiagnosticPipe; use App\Facades\Helpers; use App\Models\Configs; +use Illuminate\Support\Facades\Schema; use function Safe\exec; use Spatie\ImageOptimizer\Optimizers\Cwebp; use Spatie\ImageOptimizer\Optimizers\Gifsicle; @@ -23,6 +24,10 @@ class ImageOptCheck implements DiagnosticPipe */ public function handle(array &$data, \Closure $next): array { + if (!Schema::hasTable('configs')) { + return $next($data); + } + $tools = []; $tools[] = new Cwebp(); $tools[] = new Gifsicle(); diff --git a/app/Actions/Diagnostics/Pipes/Checks/UpdatableCheck.php b/app/Actions/Diagnostics/Pipes/Checks/UpdatableCheck.php index 7b70ea97f10..4ef6189280f 100644 --- a/app/Actions/Diagnostics/Pipes/Checks/UpdatableCheck.php +++ b/app/Actions/Diagnostics/Pipes/Checks/UpdatableCheck.php @@ -11,6 +11,7 @@ use App\Metadata\Versions\GitHubVersion; use App\Metadata\Versions\InstalledVersion; use App\Models\Configs; +use Illuminate\Support\Facades\Schema; use function Safe\exec; /** @@ -64,6 +65,9 @@ public static function assertUpdatability(): void return; // @codeCoverageIgnoreEnd } + if (!Schema::hasTable('configs')) { + throw new ConfigurationException('Migration is not run'); + } if (!Configs::getValueAsBool('allow_online_git_pull')) { throw new ConfigurationException('Online updates are disabled by configuration'); diff --git a/app/Metadata/Versions/InstalledVersion.php b/app/Metadata/Versions/InstalledVersion.php index a8803534e52..b97e6356cb1 100644 --- a/app/Metadata/Versions/InstalledVersion.php +++ b/app/Metadata/Versions/InstalledVersion.php @@ -8,6 +8,7 @@ use App\Exceptions\ConfigurationKeyMissingException; use App\Models\Configs; use Illuminate\Support\Facades\File; +use Illuminate\Support\Facades\Schema; /** * InstalledVersion contains the following info: @@ -61,6 +62,10 @@ public function isDev(): bool */ public function getVersion(): Version { + if (!Schema::hasTable('configs')) { + return Version::createFromInt(10000); + } + return Version::createFromInt(Configs::getValueAsInt('version')); } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 6b8d462c61b..78a95a7ba4e 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -99,12 +99,11 @@ public function boot() $lang = Configs::getValueAsString('lang'); app()->setLocale($lang); } catch (\Throwable $e) { - /** log and ignore. + /** Ignore. * This is necessary so that we can continue: * - if Configs table do not exists (no install), * - if the value does not exists in configs (no install),. */ - logger($e); } /**