diff --git a/app/Console/Commands/Overrides/SeedCommand.php b/app/Console/Commands/Overrides/SeedCommand.php new file mode 100644 index 000000000..91b555d4b --- /dev/null +++ b/app/Console/Commands/Overrides/SeedCommand.php @@ -0,0 +1,26 @@ +hasCompletedMigrations()) { + return $this->showMigrationWarning(); + } + + return parent::handle(); + } +} diff --git a/app/Console/Commands/Overrides/UpCommand.php b/app/Console/Commands/Overrides/UpCommand.php new file mode 100644 index 000000000..3a5f34610 --- /dev/null +++ b/app/Console/Commands/Overrides/UpCommand.php @@ -0,0 +1,23 @@ +hasCompletedMigrations()) { + return $this->showMigrationWarning(); + } + + return parent::handle(); + } +} diff --git a/app/Console/RequiresDatabaseMigrations.php b/app/Console/RequiresDatabaseMigrations.php new file mode 100644 index 000000000..f288ca1f1 --- /dev/null +++ b/app/Console/RequiresDatabaseMigrations.php @@ -0,0 +1,61 @@ +getLaravel()->make('migrator'); + + $files = $migrator->getMigrationFiles(database_path('migrations')); + + if (! $migrator->repositoryExists()) { + 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... + * + * @return int + */ + protected function showMigrationWarning(): int + { + $this->getOutput()->writeln(" +| @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | +| | +| Your database has not been properly migrated! | +| | +| @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | + +You must run the following command to finish migrating your database: + + 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. +"); + + $this->getOutput()->error("You must correct the error above before continuing."); + + return 1; + } +}