2020-10-13 03:51:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Console;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @mixin \Illuminate\Console\Command
|
|
|
|
*/
|
|
|
|
trait RequiresDatabaseMigrations
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Checks if the migrations have finished running by comparing the last migration file.
|
|
|
|
*/
|
|
|
|
protected function hasCompletedMigrations(): bool
|
|
|
|
{
|
|
|
|
/** @var \Illuminate\Database\Migrations\Migrator $migrator */
|
|
|
|
$migrator = $this->getLaravel()->make('migrator');
|
|
|
|
|
|
|
|
$files = $migrator->getMigrationFiles(database_path('migrations'));
|
|
|
|
|
2021-01-23 20:33:34 +00:00
|
|
|
if (!$migrator->repositoryExists()) {
|
2020-10-13 03:51:35 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (array_diff(array_keys($files), $migrator->getRepository()->getRan())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Throw a massive error into the console to hopefully catch the users attention and get
|
|
|
|
* them to properly run the migrations rather than ignoring all of the other previous
|
|
|
|
* errors...
|
|
|
|
*/
|
|
|
|
protected function showMigrationWarning(): int
|
|
|
|
{
|
2021-01-23 20:09:16 +00:00
|
|
|
$this->getOutput()->writeln('<options=bold>
|
2020-10-13 03:51:35 +00:00
|
|
|
| @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
|
|
|
|
| |
|
|
|
|
| Your database has not been properly migrated! |
|
|
|
|
| |
|
|
|
|
| @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |</>
|
|
|
|
|
|
|
|
You must run the following command to finish migrating your database:
|
|
|
|
|
|
|
|
<fg=green;options=bold>php artisan migrate --step --force</>
|
|
|
|
|
|
|
|
You will not be able to use Pterodactyl Panel as expected without fixing your
|
|
|
|
database state by running the command above.
|
2021-01-23 20:09:16 +00:00
|
|
|
');
|
2020-10-13 03:51:35 +00:00
|
|
|
|
2021-01-23 20:09:16 +00:00
|
|
|
$this->getOutput()->error('You must correct the error above before continuing.');
|
2020-10-13 03:51:35 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|