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