Last active
October 31, 2019 12:03
-
-
Save frak/5361df1556927443ba69ddd999cae718 to your computer and use it in GitHub Desktop.
Run Doctrine migrations on composer install
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
{ | |
"scripts": { | |
"symfony-scripts": [ | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget" | |
], | |
"default-params": [ | |
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters" | |
], | |
"post-install-cmd": [ | |
"@symfony-scripts", | |
"AppBundle\\Composer\\MigrationHandler::runMigrations" | |
], | |
"post-update-cmd": [ | |
"@symfony-scripts" | |
] | |
} | |
} |
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
<?php | |
namespace AppBundle\Composer; | |
use Composer\Script\Event; | |
use Sensio\Bundle\DistributionBundle\Composer\ScriptHandler; | |
class MigrationHandler extends ScriptHandler | |
{ | |
/** | |
* Runs the Doctrine migrations. | |
* | |
* @param Event $event | |
*/ | |
public static function runMigrations(Event $event) | |
{ | |
$options = static::getOptions($event); | |
$consoleDir = static::getConsoleDir($event, 'run database migrations'); | |
if (null === $consoleDir) { | |
return; | |
} | |
static::executeCommand($event, $consoleDir, 'doctrine:migrations:migrate -n', $options['process-timeout']); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment