mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-02 03:37:44 +08:00
Added --graceful
to migrateCommand (#6590)
This commit is contained in:
parent
813dda3c6c
commit
0e7435db45
@ -5,6 +5,7 @@
|
|||||||
- [#6576](https://github.com/hyperf/hyperf/pull/6576) Added `Hyperf\Stringable\Str::apa()` method.
|
- [#6576](https://github.com/hyperf/hyperf/pull/6576) Added `Hyperf\Stringable\Str::apa()` method.
|
||||||
- [#6577](https://github.com/hyperf/hyperf/pull/6577) Support setup command traits before running.
|
- [#6577](https://github.com/hyperf/hyperf/pull/6577) Support setup command traits before running.
|
||||||
- [#6579](https://github.com/hyperf/hyperf/pull/6579) Added `now()` and `today()` helper functions.
|
- [#6579](https://github.com/hyperf/hyperf/pull/6579) Added `now()` and `today()` helper functions.
|
||||||
|
- [#6590](https://github.com/hyperf/hyperf/pull/6590) Added `--graceful` to migrateCommand.
|
||||||
|
|
||||||
# v3.1.12 - 2024-03-07
|
# v3.1.12 - 2024-03-07
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ namespace Hyperf\Database\Commands\Migrations;
|
|||||||
use Hyperf\Command\Concerns\Confirmable as ConfirmableTrait;
|
use Hyperf\Command\Concerns\Confirmable as ConfirmableTrait;
|
||||||
use Hyperf\Database\Migrations\Migrator;
|
use Hyperf\Database\Migrations\Migrator;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
class MigrateCommand extends BaseCommand
|
class MigrateCommand extends BaseCommand
|
||||||
{
|
{
|
||||||
@ -34,9 +35,29 @@ class MigrateCommand extends BaseCommand
|
|||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
if (! $this->confirmToProceed()) {
|
if (! $this->confirmToProceed()) {
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->runMigrations();
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
if ($this->input->getOption('graceful')) {
|
||||||
|
$this->output->warning($e->getMessage());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the pending migrations.
|
||||||
|
*/
|
||||||
|
protected function runMigrations()
|
||||||
|
{
|
||||||
$this->prepareDatabase();
|
$this->prepareDatabase();
|
||||||
|
|
||||||
// Next, we will check to see if a path option has been defined. If it has
|
// Next, we will check to see if a path option has been defined. If it has
|
||||||
@ -66,6 +87,7 @@ class MigrateCommand extends BaseCommand
|
|||||||
['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run'],
|
['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run'],
|
||||||
['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run'],
|
['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run'],
|
||||||
['step', null, InputOption::VALUE_NONE, 'Force the migrations to be run so they can be rolled back individually'],
|
['step', null, InputOption::VALUE_NONE, 'Force the migrations to be run so they can be rolled back individually'],
|
||||||
|
['graceful', null, InputOption::VALUE_NONE, 'Return a successful exit code even if an error occurs'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user