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) {
|
if ($db === self::MYSQL) {
|
||||||
$column->setPlatformOption('collation', 'utf8_bin');
|
$column->setPlatformOption('collation', 'utf8_bin');
|
||||||
} elseif ($db === self::SQLITE) {
|
} elseif ($db === self::SQLITE) {
|
||||||
$column->setPlatformOption('collation', 'BINARY');
|
$column->setPlatformOption('collate', 'BINARY');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,31 +95,20 @@ class InstallCommand extends Command
|
|||||||
|
|
||||||
// Generate database
|
// Generate database
|
||||||
$output->writeln('Initializing database...');
|
$output->writeln('Initializing database...');
|
||||||
$process = $this->processHelper->run($output, 'php vendor/bin/doctrine.php orm:schema-tool:create');
|
if (! $this->runCommand('php vendor/bin/doctrine.php orm:schema-tool:create', 'Error generating database.')) {
|
||||||
if ($process->isSuccessful()) {
|
return;
|
||||||
$output->writeln(' <info>Success!</info>');
|
}
|
||||||
} else {
|
|
||||||
if ($output->isVerbose()) {
|
// Run database migrations
|
||||||
return;
|
$output->writeln('Updating database...');
|
||||||
}
|
if (! $this->runCommand('php vendor/bin/doctrine-migrations migrations:migrate', 'Error updating database.')) {
|
||||||
$output->writeln(
|
|
||||||
' <error>Error generating database.</error> Run this command with -vvv to see specific error info.'
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate proxies
|
// Generate proxies
|
||||||
$output->writeln('Generating proxies...');
|
$output->writeln('Generating proxies...');
|
||||||
$process = $this->processHelper->run($output, 'php vendor/bin/doctrine.php orm:generate-proxies');
|
if (! $this->runCommand('php vendor/bin/doctrine.php orm:generate-proxies', 'Error generating proxies.')) {
|
||||||
if ($process->isSuccessful()) {
|
return;
|
||||||
$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.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,4 +272,26 @@ class InstallCommand extends Command
|
|||||||
|
|
||||||
return $config;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
<!-- Paths to check -->
|
<!-- Paths to check -->
|
||||||
<file>bin</file>
|
<file>bin</file>
|
||||||
<file>module</file>
|
<file>module</file>
|
||||||
|
<file>data/migrations</file>
|
||||||
<file>config</file>
|
<file>config</file>
|
||||||
<file>public/index.php</file>
|
<file>public/index.php</file>
|
||||||
<exclude-pattern>config/params/*</exclude-pattern>
|
<exclude-pattern>config/params/*</exclude-pattern>
|
||||||
|
Loading…
Reference in New Issue
Block a user