Skip to content

Commit 8e8f496

Browse files
authored
Magento 2: Changed upgrading database (#3812)
* Changed step to upgrade the DB only instead of Magento and execute it once if multiple servers are selected for the deployment * Bugfix: Added once() to task instead of run commando. Regenerated docs. * Improvement: Changed documentation to reflect that the database step is only executed once.
1 parent c859ace commit 8e8f496

File tree

2 files changed

+31
-30
lines changed

2 files changed

+31
-30
lines changed

docs/recipe/magento2.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ true
353353

354354

355355
### artifact_file
356-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L343)
356+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L344)
357357

358358
The file the artifact is saved to
359359

@@ -363,7 +363,7 @@ The file the artifact is saved to
363363

364364

365365
### artifact_dir
366-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L346)
366+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L347)
367367

368368
The directory the artifact is saved in
369369

@@ -373,7 +373,7 @@ The directory the artifact is saved in
373373

374374

375375
### artifact_excludes_file
376-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L350)
376+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L351)
377377

378378
Points to a file with a list of files to exclude from packaging.
379379
The format is as with the `tar --exclude-from=[file]` option
@@ -384,7 +384,7 @@ The format is as with the `tar --exclude-from=[file]` option
384384

385385

386386
### build_from_repo
387-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L353)
387+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L354)
388388

389389
If set to true, the artifact is built from a clean copy of the project repository instead of the current working directory
390390

@@ -394,7 +394,7 @@ false
394394

395395

396396
### repository
397-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L356)
397+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L357)
398398

399399
Overrides [repository](/docs/recipe/common.md#repository) from `recipe/common.php`.
400400

@@ -406,7 +406,7 @@ null
406406

407407

408408
### artifact_path
409-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L359)
409+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L360)
410410

411411
The relative path to the artifact file. If the directory does not exist, it will be created
412412

@@ -419,7 +419,7 @@ return get('artifact_dir') . '/' . get('artifact_file');
419419

420420

421421
### bin/tar
422-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L367)
422+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L368)
423423

424424
The location of the tar command. On MacOS you should have installed gtar, as it supports the required settings
425425
:::info Autogenerated
@@ -430,14 +430,14 @@ The value of this configuration is autogenerated on access.
430430

431431

432432
### additional_shared_files
433-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L439)
433+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L440)
434434

435435
Array of shared files that will be added to the default shared_files without overriding
436436

437437

438438

439439
### additional_shared_dirs
440-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L441)
440+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L442)
441441

442442
Array of shared directories that will be added to the default shared_dirs without overriding
443443

@@ -544,21 +544,21 @@ Config Import.
544544
### magento:upgrade:db
545545
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L300)
546546

547-
Upgrades magento database.
547+
Upgrades magento database. This task is only excuted once when multiple hosts have been selected for deployment.
548548

549549

550550

551551

552552
### magento:cache:flush
553-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L309)
553+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L310)
554554

555555
Flushes Magento Cache.
556556

557557

558558

559559

560560
### deploy:magento
561-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L314)
561+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L315)
562562

563563
Magento2 deployment operations.
564564

@@ -575,7 +575,7 @@ This task is group task which contains next tasks:
575575

576576

577577
### magento:build
578-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L324)
578+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L325)
579579

580580
Magento2 build operations.
581581

@@ -588,7 +588,7 @@ This task is group task which contains next tasks:
588588

589589

590590
### deploy
591-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L330)
591+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L331)
592592

593593
Deploys your project.
594594

@@ -604,47 +604,47 @@ This task is group task which contains next tasks:
604604

605605

606606
### artifact:package
607-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L378)
607+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L379)
608608

609609
Packages all relevant files in an artifact.
610610

611611

612612

613613

614614
### artifact:upload
615-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L388)
615+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L389)
616616

617617
Uploads artifact in release folder for extraction.
618618

619619

620620

621621

622622
### artifact:extract
623-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L393)
623+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L394)
624624

625625
Extracts artifact in release path.
626626

627627

628628

629629

630630
### build:remove-generated
631-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L399)
631+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L400)
632632

633633
Clears generated files prior to building.
634634

635635

636636

637637

638638
### build:prepare
639-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L404)
639+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L405)
640640

641641
Prepare local artifact build.
642642

643643

644644

645645

646646
### artifact:build
647-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L429)
647+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L430)
648648

649649
Builds an artifact.
650650

@@ -661,15 +661,15 @@ This task is group task which contains next tasks:
661661

662662

663663
### deploy:additional-shared
664-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L445)
664+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L446)
665665

666666
Adds additional files and dirs to the list of shared files and dirs.
667667

668668

669669

670670

671671
### magento:set_cache_prefix
672-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L460)
672+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L461)
673673

674674
Update cache id_prefix.
675675

@@ -683,15 +683,15 @@ after('deploy:magento', 'magento:cleanup_cache_prefix');
683683

684684

685685
### magento:cleanup_cache_prefix
686-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L500)
686+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L501)
687687

688688
Cleanup cache id_prefix env files.
689689

690690
After successful deployment, move the tmp_env.php file to env.php ready for next deployment
691691

692692

693693
### magento:cron:stop
694-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L516)
694+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L517)
695695

696696
Remove cron from crontab and kill running cron jobs.
697697

@@ -703,7 +703,7 @@ To use this feature, add the following to your deployer scripts:
703703

704704

705705
### magento:cron:install
706-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L532)
706+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L533)
707707

708708
Install cron in crontab.
709709

@@ -715,7 +715,7 @@ To use this feature, add the following to your deployer scripts:
715715

716716

717717
### artifact:prepare
718-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L538)
718+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L539)
719719

720720
Prepares an artifact on the target server.
721721

@@ -735,7 +735,7 @@ This task is group task which contains next tasks:
735735

736736

737737
### artifact:finish
738-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L551)
738+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L552)
739739

740740
Executes the tasks after artifact is released.
741741

@@ -750,7 +750,7 @@ This task is group task which contains next tasks:
750750

751751

752752
### artifact:deploy
753-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L560)
753+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L561)
754754

755755
Actually releases the artifact deployment.
756756

recipe/magento2.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,12 @@ function magentoDeployAssetsSplit(string $area)
299299
desc('Upgrades magento database');
300300
task('magento:upgrade:db', function () {
301301
if (get('database_upgrade_needed')) {
302-
run("{{bin/php}} {{bin/magento}} setup:upgrade --keep-generated --no-interaction");
302+
run("{{bin/php}} {{bin/magento}} setup:db-schema:upgrade --no-interaction");
303+
run("{{bin/php}} {{bin/magento}} setup:db-data:upgrade --no-interaction");
303304
} else {
304305
writeln('Database schema is up to date => upgrade skipped');
305306
}
306-
});
307+
})->once();
307308

308309
desc('Flushes Magento Cache');
309310
task('magento:cache:flush', function () {

0 commit comments

Comments
 (0)