Skip to content

Commit

Permalink
Add sw:plugin:activate:all and sw:plugin:migrate:all to Shopware 6 re…
Browse files Browse the repository at this point in the history
…cipe (#2159)

Do not update upgradeable plugins, it updates code too. What we actually want is to run the migration. But the database:migrate --all command only runs the migrations for the core. Added a task that runs migrations for all plugins too.

Added || true to not let it fail on non-existing database migrations. This can be removed when this commit is released; shopware/shopware@2a8a76f
  • Loading branch information
peterjaap committed Sep 10, 2020
1 parent f16e0cb commit c19b1dc
Showing 1 changed file with 39 additions and 8 deletions.
47 changes: 39 additions & 8 deletions recipe/shopware6.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,19 @@
task('sw:database:migrate', static function () {
run('cd {{release_path}} && bin/console database:migrate --all');
});
task('sw:plugins:installActivateUpgrade', static function () {
task('sw:plugin:refresh', function (){
run('cd {{release_path}} && bin/console plugin:refresh');
});
task('sw:plugin:activate:all', static function () {
task('sw:plugin:refresh');
$plugins = explode("\n", run('cd {{release_path}} && bin/console plugin:list'));

// take line over headlines and count "-" to get the size of the cells
// take line over headlines and count "-" to get the size of the cells
$lengths = array_filter(array_map('strlen', explode(' ', $plugins[4])));

// ignore first seven lines (headline, title, table, ...)
// ignore first seven lines (headline, title, table, ...)
$plugins = array_slice($plugins, 7, -3);
foreach ($plugins as $plugin) {
// PayonePayment PAYONE Payment 2.0.0 PAYONE GmbH, Kellerkinder Pluginwerk GmbH No No No

$pluginParts = [];
foreach ($lengths as $length) {
$pluginParts[] = trim(substr($plugin, 0, $length));
Expand All @@ -88,9 +90,37 @@
if ($installed === 'No' || $active === 'No') {
run("cd {{release_path}} && bin/console plugin:install --activate $plugin");
}
}
});
task('sw:plugin:migrate:all', static function(){
$plugins = explode("\n", run('cd {{release_path}} && bin/console plugin:list'));

// take line over headlines and count "-" to get the size of the cells
$lengths = array_filter(array_map('strlen', explode(' ', $plugins[4])));

// ignore first seven lines (headline, title, table, ...)
$plugins = array_slice($plugins, 7, -3);
foreach ($plugins as $plugin) {
$pluginParts = [];
foreach ($lengths as $length) {
$pluginParts[] = trim(substr($plugin, 0, $length));
$plugin = substr($plugin, $length + 1);
}

[
$plugin,
$label,
$version,
$upgrade,
$version,
$author,
$installed,
$active,
$upgradeable,
] = $pluginParts;

if ($upgradeable === 'Yes') {
run("cd {{release_path}} && bin/console plugin:update -c $plugin");
if ($installed === 'Yes' || $active === 'Yes') {
run("cd {{release_path}} && bin/console database:migrate --all $plugin || true");
}
}
});
Expand All @@ -99,9 +129,10 @@
* Grouped SW deploy tasks
*/
task('sw:deploy', [
// 'sw:plugins:installActivateUpgrade',
'sw:build',
'sw:plugin:activate:all',
'sw:database:migrate',
'sw:plugin:migrate:all',
'sw:theme:compile',
'sw:cache:clear',
]);
Expand Down

0 comments on commit c19b1dc

Please sign in to comment.