mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-23 07:33:58 -06:00
Improved check on update and install commands
This commit is contained in:
parent
c3cc88f03e
commit
1fe2e6f6bd
@ -100,9 +100,15 @@ abstract class AbstractInstallCommand extends Command
|
||||
$this->configWriter->toFile('config/params/generated_config.php', $config, false);
|
||||
$output->writeln(['<info>Custom configuration properly generated!</info>', '']);
|
||||
|
||||
// Generate database
|
||||
if (! $this->createDatabase()) {
|
||||
return;
|
||||
// If current command is not update, generate database
|
||||
if (! $this->isUpdate()) {
|
||||
$this->output->writeln('Initializing database...');
|
||||
if (! $this->runCommand(
|
||||
'php vendor/bin/doctrine.php orm:schema-tool:create',
|
||||
'Error generating database.'
|
||||
)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Run database migrations
|
||||
@ -295,11 +301,6 @@ abstract class AbstractInstallCommand extends Command
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function createDatabase();
|
||||
|
||||
/**
|
||||
* @param string $command
|
||||
* @param string $errorMessage
|
||||
@ -322,4 +323,9 @@ abstract class AbstractInstallCommand extends Command
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function isUpdate();
|
||||
}
|
||||
|
@ -3,9 +3,11 @@ namespace Shlinkio\Shlink\CLI\Command\Install;
|
||||
|
||||
class InstallCommand extends AbstractInstallCommand
|
||||
{
|
||||
protected function createDatabase()
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function isUpdate()
|
||||
{
|
||||
$this->output->writeln('Initializing database...');
|
||||
return $this->runCommand('php vendor/bin/doctrine.php orm:schema-tool:create', 'Error generating database.');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,10 @@ namespace Shlinkio\Shlink\CLI\Command\Install;
|
||||
|
||||
class UpdateCommand extends AbstractInstallCommand
|
||||
{
|
||||
public function createDatabase()
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function isUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user