1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 18:04:03 +00:00

Fix rollback command (#14)

* Add and use setParameterDefaults()

* Correct rollback test

* Check ignored parameters instead of directly checking the command's options

* Delete --path setting from the test

* Revert test changes

* Delete new lines
This commit is contained in:
lukinovec 2023-10-16 01:50:59 +02:00 committed by GitHub
parent ab240fb675
commit b503dbf33d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,11 +27,7 @@ class Rollback extends RollbackCommand
public function handle(): int
{
foreach (config('tenancy.migration_parameters') as $parameter => $value) {
if (! $this->input->hasParameterOption($parameter)) {
$this->input->setOption(ltrim($parameter, '-'), $value);
}
}
$this->setParameterDefaults();
if (! $this->confirmToProceed()) {
return 1;
@ -55,4 +51,22 @@ class Rollback extends RollbackCommand
{
return 'tenants:rollback';
}
protected function setParameterDefaults(): void
{
// Parameters that this command doesn't support, but can be in tenancy.migration_parameters
$ignoredParameters = [
'--seed',
'--seeder',
'--isolated',
'--schema-path',
];
foreach (config('tenancy.migration_parameters') as $parameter => $value) {
// Only set the default if the option isn't set
if (! in_array($parameter, $ignoredParameters) && ! $this->input->hasParameterOption($parameter)) {
$this->input->setOption(ltrim($parameter, '-'), $value);
}
}
}
}