Skip to content

Commit

Permalink
✨ [EIC-881] Adicionando configuração para desativar seed
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoapaes authored Sep 10, 2024
1 parent 35be2ce commit ef32fc4
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/Phinx.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,20 @@ public function _before(TestInterface $test) {
$populate = $this->getModule('Db')->_getConfig('populate');

if ($populate) {
$this->phinx();
$this->phinx($this->getSeedConfig());
}
}

private function phinx() {
private function getSeedConfig() {
$seed = $this->_getConfig('seed');
if($seed === null) {
$seed = true;
}

return boolval($seed);
}

private function phinx($seed) {
$config = $this->findConfigPath();

$app = new PhinxApplication();
Expand All @@ -26,7 +35,10 @@ private function phinx() {
$output = new BufferedOutput();

$this->run($app, $output, 'migrate', $config);
$this->run($app, $output, 'seed:run', $config);

if($seed) {
$this->run($app, $output, 'seed:run', $config);
}
}

private function run(PhinxApplication $phinx, BufferedOutput $output, $commandName, $config, $environment='production') {
Expand Down

0 comments on commit ef32fc4

Please sign in to comment.