Path: blob/1.0-develop/app/Console/RequiresDatabaseMigrations.php
7432 views
<?php12namespace Pterodactyl\Console;34/**5* @mixin \Illuminate\Console\Command6*/7trait RequiresDatabaseMigrations8{9/**10* Checks if the migrations have finished running by comparing the last migration file.11*/12protected function hasCompletedMigrations(): bool13{14/** @var \Illuminate\Database\Migrations\Migrator $migrator */15$migrator = $this->getLaravel()->make('migrator');1617$files = $migrator->getMigrationFiles(database_path('migrations'));1819if (!$migrator->repositoryExists()) {20return false;21}2223if (array_diff(array_keys($files), $migrator->getRepository()->getRan())) {24return false;25}2627return true;28}2930/**31* Throw a massive error into the console to hopefully catch the users attention and get32* them to properly run the migrations rather than ignoring all of the other previous33* errors...34*/35protected function showMigrationWarning(): void36{37$this->getOutput()->writeln('<options=bold>38| @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |39| |40| Your database has not been properly migrated! |41| |42| @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |</>4344You must run the following command to finish migrating your database:4546<fg=green;options=bold>php artisan migrate --step --force</>4748You will not be able to use Pterodactyl Panel as expected without fixing your49database state by running the command above.50');5152$this->getOutput()->error('You must correct the error above before continuing.');53}54}555657