-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2.0
- Loading branch information
Showing
28 changed files
with
461 additions
and
131 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,5 @@ install: | |
- composer install | ||
|
||
script: | ||
- phpunit tests/SqliteCommandTest.php | ||
- phpunit tests/SqliteDatabaseTest.php | ||
|
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
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 was deleted.
Oops, something went wrong.
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
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,51 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: jg | ||
* Date: 17/06/16 | ||
* Time: 21:52 | ||
*/ | ||
|
||
namespace ByJG\DbMigration\Console; | ||
|
||
use ByJG\DbMigration\Exception\DatabaseNotVersionedException; | ||
use ByJG\DbMigration\Exception\OldVersionSchemaException; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class InstallCommand extends ConsoleCommand | ||
{ | ||
protected function configure() | ||
{ | ||
parent::configure(); | ||
$this | ||
->setName('install') | ||
->setDescription('Install or upgrade the migrate version in a existing database'); | ||
|
||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
try { | ||
parent::execute($input, $output); | ||
|
||
$action = 'Database is already versioned. '; | ||
try { | ||
$this->migration->getCurrentVersion(); | ||
} catch (DatabaseNotVersionedException $ex) { | ||
$action = 'Created the version table'; | ||
$this->migration->createVersion(); | ||
} catch (OldVersionSchemaException $ex) { | ||
$action = 'Updated the version table'; | ||
$this->migration->updateTableVersion(); | ||
} | ||
|
||
$version = $this->migration->getCurrentVersion(); | ||
$output->writeln($action); | ||
$output->writeln('current version: ' . $version['version']); | ||
$output->writeln('current status.: ' . $version['status']); | ||
} catch (\Exception $ex) { | ||
$this->handleError($ex, $output); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.