Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Console/RequiresDatabaseMigrations.php
7432 views
1
<?php
2
3
namespace Pterodactyl\Console;
4
5
/**
6
* @mixin \Illuminate\Console\Command
7
*/
8
trait RequiresDatabaseMigrations
9
{
10
/**
11
* Checks if the migrations have finished running by comparing the last migration file.
12
*/
13
protected function hasCompletedMigrations(): bool
14
{
15
/** @var \Illuminate\Database\Migrations\Migrator $migrator */
16
$migrator = $this->getLaravel()->make('migrator');
17
18
$files = $migrator->getMigrationFiles(database_path('migrations'));
19
20
if (!$migrator->repositoryExists()) {
21
return false;
22
}
23
24
if (array_diff(array_keys($files), $migrator->getRepository()->getRan())) {
25
return false;
26
}
27
28
return true;
29
}
30
31
/**
32
* Throw a massive error into the console to hopefully catch the users attention and get
33
* them to properly run the migrations rather than ignoring all of the other previous
34
* errors...
35
*/
36
protected function showMigrationWarning(): void
37
{
38
$this->getOutput()->writeln('<options=bold>
39
| @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
40
| |
41
| Your database has not been properly migrated! |
42
| |
43
| @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |</>
44
45
You must run the following command to finish migrating your database:
46
47
<fg=green;options=bold>php artisan migrate --step --force</>
48
49
You will not be able to use Pterodactyl Panel as expected without fixing your
50
database state by running the command above.
51
');
52
53
$this->getOutput()->error('You must correct the error above before continuing.');
54
}
55
}
56
57