Skip to content

Commit

Permalink
Merge pull request #143 from marlon-be/feature/symfony5
Browse files Browse the repository at this point in the history
add support for Symfony 5 components
  • Loading branch information
davedevelopment authored Dec 27, 2019
2 parents 815d6b5 + a250ad4 commit 4e71b88
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 21 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
}],
"require": {
"php": ">=5.3.2",
"symfony/console": "^2.0||^3.0||^4.0",
"symfony/config": "^2.0||^3.0||^4.0"
"symfony/console": "^2.0||^3.0||^4.0||^5.0",
"symfony/config": "^2.0||^3.0||^4.0||^5.0"
},
"require-dev": {
"phpunit/phpunit": "3.*",
Expand Down
6 changes: 4 additions & 2 deletions src/Phpmig/Console/Command/DownCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
$version = $input->getArgument('version');

if (!in_array($version, $versions)) {
return;
return 0;
}

if (!isset($migrations[$version])) {
return;
return 0;
}

$container = $this->getContainer();
$container['phpmig.migrator']->down($migrations[$version]);

return 0;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Phpmig/Console/Command/GenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function down()
'.' . str_replace(getcwd(), '', $path)
);

return;
return 0;
}

protected function transMigName($migrationName)
Expand Down
2 changes: 2 additions & 0 deletions src/Phpmig/Console/Command/MigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$container['phpmig.migrator']->up($migration);
}
}

return 0;
}
}
6 changes: 4 additions & 2 deletions src/Phpmig/Console/Command/RedoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
$version = $input->getArgument('version');

if (!in_array($version, $versions)) {
return;
return 0;
}

if (!isset($migrations[$version])) {
return;
return 0;
}

$container = $this->getContainer();
$container['phpmig.migrator']->down($migrations[$version]);
$container['phpmig.migrator']->up($migrations[$version]);

return 0;
}
}

Expand Down
14 changes: 8 additions & 6 deletions src/Phpmig/Console/Command/RollbackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$migrations = $this->getMigrations();
$versions = $this->getAdapter()->fetchAll();

$version = $input->getOption('target');

ksort($migrations);
Expand All @@ -64,9 +64,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
// Check we have at least 1 migration to revert
if (empty($versions) || $version == end($versions)) {
$output->writeln("<error>No migrations to rollback</error>");
return;
return 0;
}

// If no target version was supplied, revert the last migration
if (null === $version) {
// Get the migration before the last run migration
Expand All @@ -75,17 +75,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
} else {
// Get the first migration number
$first = reset($versions);

// If the target version is before the first migration, revert all migrations
if ($version < $first) {
$version = 0;
}
}

// Check the target version exists
if (0 !== $version && !isset($migrations[$version])) {
$output->writeln("<error>Target version ($version) not found</error>");
return;
return 0;
}

// Revert the migration(s)
Expand All @@ -100,5 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$container['phpmig.migrator']->down($migration);
}
}

return 0;
}
}
12 changes: 6 additions & 6 deletions src/Phpmig/Console/Command/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$versions = $this->getAdapter()->fetchAll();
foreach($this->getMigrations() as $migration) {

if (in_array($migration->getVersion(), $versions)) {
$status = " <info>up</info> ";
unset($versions[array_search($migration->getVersion(), $versions)]);
Expand All @@ -63,23 +63,23 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$output->writeln(
$status .
sprintf(" %14s ", $migration->getVersion()) .
$status .
sprintf(" %14s ", $migration->getVersion()) .
" <comment>" . $migration->getName() . "</comment>"
);
}

foreach($versions as $missing) {
$output->writeln(
' <error>up</error> ' .
sprintf(" %14s ", $missing) .
' <error>up</error> ' .
sprintf(" %14s ", $missing) .
' <error>** MISSING **</error> '
);
}

// print status
$output->writeln("");
return;
return 0;
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/Phpmig/Console/Command/UpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
$version = $input->getArgument('version');

if (in_array($version, $versions)) {
return;
return 0;
}

if (!isset($migrations[$version])) {
return;
return 0;
}

$container = $this->getContainer();
$container['phpmig.migrator']->up($migrations[$version]);

return 0;
}
}

Expand Down

0 comments on commit 4e71b88

Please sign in to comment.