This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* поддержка поддиректорий * fix * команда для архивации * try fix
- Loading branch information
Showing
5 changed files
with
140 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace Arrilot\BitrixMigrations\Commands; | ||
|
||
use Arrilot\BitrixMigrations\Migrator; | ||
use Symfony\Component\Console\Input\InputOption; | ||
|
||
class ArchiveCommand extends AbstractCommand | ||
{ | ||
/** | ||
* Migrator instance. | ||
* | ||
* @var Migrator | ||
*/ | ||
protected $migrator; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param Migrator $migrator | ||
*/ | ||
public function __construct(Migrator $migrator) | ||
{ | ||
$this->migrator = $migrator; | ||
|
||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Configures the current command. | ||
*/ | ||
protected function configure() | ||
{ | ||
$this->setName('archive') | ||
->setDescription('Move migration into archive') | ||
->addOption('without', 'w', InputOption::VALUE_REQUIRED, 'Archive without last N migration'); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return null|int | ||
*/ | ||
protected function fire() | ||
{ | ||
$files = $this->migrator->getAllMigrations(); | ||
$without = $this->input->getOption('without') ?: 0; | ||
if ($without > 0) { | ||
$files = array_slice($files, 0, $without * -1); | ||
} | ||
|
||
$count = $this->migrator->moveMigrationFiles($files); | ||
|
||
if ($count) { | ||
$this->message("<info>Moved to archive:</info> {$count}"); | ||
} else { | ||
$this->info('Nothing to move'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters