mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-22 15:13:59 -06:00
Improved InstallCommand, adding migrations and removing code duplication
This commit is contained in:
parent
7d49c1760c
commit
ea083e30b6
@ -25,7 +25,7 @@ class Version20160819142757 extends AbstractMigration
|
||||
if ($db === self::MYSQL) {
|
||||
$column->setPlatformOption('collation', 'utf8_bin');
|
||||
} elseif ($db === self::SQLITE) {
|
||||
$column->setPlatformOption('collation', 'BINARY');
|
||||
$column->setPlatformOption('collate', 'BINARY');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,31 +95,20 @@ class InstallCommand extends Command
|
||||
|
||||
// Generate database
|
||||
$output->writeln('Initializing database...');
|
||||
$process = $this->processHelper->run($output, 'php vendor/bin/doctrine.php orm:schema-tool:create');
|
||||
if ($process->isSuccessful()) {
|
||||
$output->writeln(' <info>Success!</info>');
|
||||
} else {
|
||||
if ($output->isVerbose()) {
|
||||
return;
|
||||
}
|
||||
$output->writeln(
|
||||
' <error>Error generating database.</error> Run this command with -vvv to see specific error info.'
|
||||
);
|
||||
if (! $this->runCommand('php vendor/bin/doctrine.php orm:schema-tool:create', 'Error generating database.')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Run database migrations
|
||||
$output->writeln('Updating database...');
|
||||
if (! $this->runCommand('php vendor/bin/doctrine-migrations migrations:migrate', 'Error updating database.')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate proxies
|
||||
$output->writeln('Generating proxies...');
|
||||
$process = $this->processHelper->run($output, 'php vendor/bin/doctrine.php orm:generate-proxies');
|
||||
if ($process->isSuccessful()) {
|
||||
$output->writeln(' <info>Success!</info>');
|
||||
} else {
|
||||
if ($output->isVerbose()) {
|
||||
return;
|
||||
}
|
||||
$output->writeln(
|
||||
' <error>Error generating proxies.</error> Run this command with -vvv to see specific error info.'
|
||||
);
|
||||
if (! $this->runCommand('php vendor/bin/doctrine.php orm:generate-proxies', 'Error generating proxies.')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -283,4 +272,26 @@ class InstallCommand extends Command
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $command
|
||||
* @param string $errorMessage
|
||||
* @return bool
|
||||
*/
|
||||
protected function runCommand($command, $errorMessage)
|
||||
{
|
||||
$process = $this->processHelper->run($this->output, $command);
|
||||
if ($process->isSuccessful()) {
|
||||
$this->output->writeln(' <info>Success!</info>');
|
||||
return true;
|
||||
} else {
|
||||
if ($this->output->isVerbose()) {
|
||||
return false;
|
||||
}
|
||||
$this->output->writeln(
|
||||
' <error>' . $errorMessage . '</error> Run this command with -vvv to see specific error info.'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user