Skip to content

[#2379] Added 'reload-db2' ahoy command for migration database container.#2421

Merged
AlexSkrypnyk merged 7 commits intomainfrom
feature/2379-reload-db2
Mar 25, 2026
Merged

[#2379] Added 'reload-db2' ahoy command for migration database container.#2421
AlexSkrypnyk merged 7 commits intomainfrom
feature/2379-reload-db2

Conversation

@AlexSkrypnyk
Copy link
Copy Markdown
Member

@AlexSkrypnyk AlexSkrypnyk commented Mar 25, 2026

Closes #2379

Summary

Added a reload-db2 ahoy command that allows developers to reload the migration database container using the local database image. This mirrors the existing reload-db command but targets the database2 container used for migration workflows. The command was added to the main .ahoy.yml, all relevant installer fixture snapshots, and covered by a new functional subtest.

Changes

.ahoy.yml

  • Added reload-db2 command (under #;< MIGRATION / #;> MIGRATION guards) that stops and removes the database2 container, then rebuilds and restarts it via ahoy up -- --build database2. Includes a confirmation prompt before proceeding.

Installer fixture snapshots (all migration-related .ahoy.yml fixtures updated identically):

  • migration_download_source_acquia, migration_download_source_ftp, migration_download_source_lagoon, migration_download_source_s3, migration_download_source_url, migration_enabled, migration_enabled_circleci, migration_enabled_lagoon
  • Each fixture's patch diff now includes the reload-db2 command block alongside the already-present download-db2 block.

Tests

  • SubtestAhoyTrait.php: Added assertion that .ahoy.yml contains reload-db2 inside subtestAhoyMigrationSetup, plus a new subtestAhoyMigrationReloadDb() method that exercises ahoy reload-db2 and verifies that provisioning with migration succeeds after the reload.
  • AhoyWorkflowTest.php: Wired subtestAhoyMigrationReloadDb() into the migration workflow test sequence.

Before / After

Before                                    After
──────────────────────────────────────    ──────────────────────────────────────
Migration commands in .ahoy.yml:          Migration commands in .ahoy.yml:
  download-db2                              download-db2
  reload-db  (main DB only)                reload-db
                                            reload-db2  ← NEW (targets database2)

Installer fixtures:                       Installer fixtures:
  patch includes download-db2 only          patch includes download-db2 +
                                            reload-db2

Functional tests:                         Functional tests:
  subtestAhoyMigrationSetup               subtestAhoyMigrationSetup
    asserts download-db2 present            asserts download-db2 + reload-db2
  (no reload-db2 subtest)                 subtestAhoyMigrationReloadDb  ← NEW

Summary by CodeRabbit

  • New Features

    • Added a reload-db2 command to confirm, rebuild, and restart the migration database container.
    • Added a migration-image prompt to accept a container-registry image and a commented .env template for VORTEX_DB2_IMAGE.
    • Docker Compose now allows overriding the migration DB image via VORTEX_DB2_IMAGE.
  • Tests

    • Added and extended tests covering the migration-image prompt, reload-db2 workflow, and recovery verification.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 25, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds container-registry support for the migration DB image (VORTEX_DB2_IMAGE), a MigrationImage prompt handler and tests, makes database2 image configurable in docker-compose, adds an Ahoy reload-db2 command, and exercises reload-from-image in functional subtests.

Changes

Cohort / File(s) Summary
Ahoy command
\.ahoy\.yml
Added reload-db2 command in MIGRATION: confirmation, docker compose rm --force --stop --volumes database2, then ahoy up -- --build database2.
Docker / env
docker-compose.yml, \.env
Made services.database2.image configurable via ${VORTEX_DB2_IMAGE:-...}; added commented .env template for VORTEX_DB2_IMAGE.
Installer prompts
.vortex/installer/src/Prompts/Handlers/MigrationDownloadSource.php, .vortex/installer/src/Prompts/Handlers/MigrationImage.php, .vortex/installer/src/Prompts/PromptManager.php
Added CONTAINER_REGISTRY option; new MigrationImage handler (discovery, validation, dotenv write); registered handler in PromptManager and response summaries.
Functional tests / subtests
.vortex/tests/phpunit/Functional/AhoyWorkflowTest.php, .vortex/tests/phpunit/Traits/Subtests/SubtestAhoyTrait.php
Added testAhoyWorkflowMigrationDatabaseFromImage() and subtestAhoyMigrationReloadDb() to validate .ahoy.yml reload-db2, simulate table drop, run ahoy reload-db2, and verify tables restored.
Installer tests — process / unit / discovery / schema
.vortex/installer/tests/Functional/Handlers/MigrationDownloadSourceHandlerProcessTest.php, .vortex/installer/tests/Unit/Handlers/*, .vortex/installer/tests/Unit/Schema/SchemaGeneratorTest.php, .vortex/installer/tests/Unit/Handlers/MigrationImageHandlerDiscoveryTest.php
Extended datasets and added tests to cover container_registry path and MigrationImage handler (discovery, defaults, type inference, schema depends_on).

Sequence Diagram(s)

sequenceDiagram
  participant User as User
  participant Installer as Installer (PromptManager)
  participant Env as .env / Config
  participant Ahoy as Ahoy CLI
  participant Docker as Docker Compose
  participant DB as database2 container

  User->>Installer: enable Migration + choose Container registry
  Installer->>Installer: prompt MigrationImage, validate, discover
  Installer->>Env: write VORTEX_DB2_IMAGE
  User->>Ahoy: run `ahoy reload-db2`
  Ahoy->>Docker: docker compose rm --force --stop --volumes database2
  Ahoy->>Docker: docker compose up --build database2
  Docker->>DB: start container with specified image
  DB-->>Ahoy: container ready
  Ahoy-->>User: command completes
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I found an image with a tag so neat,
I told the prompts to save that treat.
Volumes swept and containers new,
database2 hopped back—tables too!
I thumped in joy: rebuild and chew!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes changes beyond the core reload-db2 command: it adds MigrationImage handler, MigrationDownloadSource.CONTAINER_REGISTRY, and related installer/test infrastructure for container registry database image sourcing. Verify whether container registry database image sourcing and related installer changes (MigrationImage, CONTAINER_REGISTRY) are within the scope of issue #2379 or should be addressed separately.
Docstring Coverage ⚠️ Warning Docstring coverage is 62.07% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a 'reload-db2' ahoy command for the migration database container, which matches the primary objective of the PR.
Linked Issues check ✅ Passed The PR successfully implements all requirements from #2379: adds reload-db2 command with correct usage/behavior, integrates it into .ahoy.yml within MIGRATION guards, and includes comprehensive tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/2379-reload-db2

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.ahoy.yml:
- Around line 166-168: Update the reload-db2 command so the confirmation prompt
explicitly references the migration database and remove the ineffective --build
flag when bringing up the database2 service: change the ahoy confirm message to
mention "migration database" (e.g., ahoy confirm "Running this command will
replace your migration database. Are you sure?") and replace the ahoy up
invocation that currently uses "-- --build database2" with a simple ahoy up --
database2 (or equivalent without --build) to avoid passing a no-op build flag
for the image-backed service.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e0aa3156-d5cd-43ab-8f89-92cf994d1311

📥 Commits

Reviewing files that changed from the base of the PR and between f2fb245 and 9148dbe.

⛔ Files ignored due to path filters (8)
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_acquia/.ahoy.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_ftp/.ahoy.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_lagoon/.ahoy.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_s3/.ahoy.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_url/.ahoy.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_enabled/.ahoy.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.ahoy.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_enabled_lagoon/.ahoy.yml is excluded by !.vortex/installer/tests/Fixtures/**
📒 Files selected for processing (3)
  • .ahoy.yml
  • .vortex/tests/phpunit/Functional/AhoyWorkflowTest.php
  • .vortex/tests/phpunit/Traits/Subtests/SubtestAhoyTrait.php

Comment on lines +166 to +168
ahoy confirm "Running this command will replace your current database. Are you sure?" || exit 0
docker compose rm --force --stop --volumes database2
ahoy up -- --build database2
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Inspect reload-db2 command in .ahoy.yml"
rg -n -C2 'reload-db2|--build database2|replace your current database' .ahoy.yml

echo
echo "Inspect database2 service definition in docker-compose.yml"
awk '
  /^database2:/ {in_block=1}
  in_block {print}
  in_block && /^  #;> MIGRATION/ {exit}
' docker-compose.yml

echo
echo "Expectation:"
echo "- database2 block contains image:"
echo "- database2 block does NOT contain build:"
echo "- then --build is a no-op for that service"

Repository: drevops/vortex

Length of output: 963


🏁 Script executed:

# Find and read the database2 service definition in docker-compose.yml
rg -A 20 "^database2:" docker-compose.yml

Repository: drevops/vortex

Length of output: 40


🏁 Script executed:

# First, check if docker-compose.yml exists and find database2 anywhere in it
echo "=== Checking for docker-compose.yml files ==="
find . -name "docker-compose*.yml" -o -name "docker-compose*.yaml" | head -20

echo
echo "=== Searching for database2 in docker-compose files ==="
rg "database2" -l docker-compose* 2>/dev/null || echo "No files matched"

echo
echo "=== Searching for database2 anywhere ==="
rg "database2" --type yaml 2>/dev/null | head -30

Repository: drevops/vortex

Length of output: 2770


🏁 Script executed:

# Read docker-compose.yml and extract the database2 service definition
rg -A 30 "^database2:" docker-compose.yml

Repository: drevops/vortex

Length of output: 40


🏁 Script executed:

# Read the docker-compose.yml file and extract database2 service
cat docker-compose.yml | grep -A 30 "database2:" | head -40

Repository: drevops/vortex

Length of output: 1209


The reload-db2 command has two issues that should be corrected.

Line 166 should explicitly mention the migration database in the confirmation prompt, and Line 168's --build flag is ineffective since database2 (which uses image: uselagoon/mysql-8.4:26.2.0) has no build: definition.

Suggested fix
-      ahoy confirm "Running this command will replace your current database. Are you sure?" || exit 0
+      ahoy confirm "Running this command will replace your current migration database. Are you sure?" || exit 0
       docker compose rm --force --stop --volumes database2
-      ahoy up -- --build database2
+      ahoy up -- database2
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.ahoy.yml around lines 166 - 168, Update the reload-db2 command so the
confirmation prompt explicitly references the migration database and remove the
ineffective --build flag when bringing up the database2 service: change the ahoy
confirm message to mention "migration database" (e.g., ahoy confirm "Running
this command will replace your migration database. Are you sure?") and replace
the ahoy up invocation that currently uses "-- --build database2" with a simple
ahoy up -- database2 (or equivalent without --build) to avoid passing a no-op
build flag for the image-backed service.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.14%. Comparing base (f2fb245) to head (96bdee4).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
.../installer/src/Prompts/Handlers/MigrationImage.php 78.57% 6 Missing ⚠️
.vortex/installer/src/Prompts/PromptManager.php 75.00% 2 Missing ⚠️
...Unit/Handlers/AbstractHandlerDiscoveryTestCase.php 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2421      +/-   ##
==========================================
- Coverage   79.64%   79.14%   -0.51%     
==========================================
  Files         126      120       -6     
  Lines        6761     6642     -119     
  Branches       44        0      -44     
==========================================
- Hits         5385     5257     -128     
- Misses       1376     1385       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

This comment has been minimized.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.vortex/installer/src/Prompts/Handlers/MigrationImage.php:
- Around line 30-37: Extract the duplicated migration-image formatting into a
single helper (e.g., a private static method like buildMigrationImageTemplate or
migrationImageTemplate) and update both placeholder(array $responses) and the
default-generating method (the one around lines 60-70) to call this helper; the
helper should accept the two inputs pulled from $responses using
OrgMachineName::id() and MachineName::id(), apply Converter::phpNamespace and
strtolower, and return the sprintf string ('E.g. %s/%s-data-migration:latest' or
the corresponding default value) so the formatting logic exists in one place and
both methods delegate to it.

In @.vortex/tests/phpunit/Functional/AhoyWorkflowTest.php:
- Around line 309-311: The test currently logs "Verify migration database image
configuration" and asserts the VORTEX_DB2_IMAGE value via
assertFileContainsString; add an additional assertion to verify the migration DB
workflow source by asserting the .env contains
"VORTEX_DOWNLOAD_DB2_SOURCE=container_registry" (use the same pattern and helper
used in this file—e.g., alongside the existing call in the same test method that
calls $this->logSubstep and $this->assertFileContainsString—to ensure the
selected path is validated end-to-end).

In @.vortex/tests/phpunit/Traits/Subtests/SubtestAhoyTrait.php:
- Line 907: The interactive call $this->cmd('ahoy reload-db2', txt: '`ahoy
reload-db2` reloads migration database container', tio: 60) can hang in CI;
update the SubtestAhoyTrait to make this invocation non-interactive by supplying
confirmation input or an explicit non-interactive flag. Locate the $this->cmd
call for 'ahoy reload-db2' and either pass a confirmation input (e.g., simulate
"y\n" via the cmd helper's input parameter) or add the appropriate ahoy flag
(e.g., --yes/--force) so the command completes without prompting.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b44ee997-5c77-45ae-aaa7-cf80363888d2

📥 Commits

Reviewing files that changed from the base of the PR and between 9148dbe and 930c30a.

⛔ Files ignored due to path filters (22)
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_acquia/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/.ahoy.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/.env is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/.github/workflows/build-test-deploy.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/.gitignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/composer.json is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/scripts/custom/provision-20-migration.sh is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/tests/phpunit/Drupal/DatabaseSettingsTest.php is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/tests/phpunit/Drupal/EnvironmentSettingsTest.php is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/tests/phpunit/Drupal/SettingsTestCase.php is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/web/modules/custom/ys_migrate/migrations/ys_migrate_categories.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/web/modules/custom/ys_migrate/ys_migrate.info.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/web/sites/default/settings.migration.php is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/web/sites/default/settings.php is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_ftp/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_lagoon/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_s3/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_url/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_enabled/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_enabled_lagoon/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
📒 Files selected for processing (12)
  • .env
  • .vortex/installer/src/Prompts/Handlers/MigrationDownloadSource.php
  • .vortex/installer/src/Prompts/Handlers/MigrationImage.php
  • .vortex/installer/src/Prompts/PromptManager.php
  • .vortex/installer/tests/Functional/Handlers/MigrationDownloadSourceHandlerProcessTest.php
  • .vortex/installer/tests/Unit/Handlers/AbstractHandlerDiscoveryTestCase.php
  • .vortex/installer/tests/Unit/Handlers/AbstractHandlerTypeTest.php
  • .vortex/installer/tests/Unit/Handlers/MigrationImageHandlerDiscoveryTest.php
  • .vortex/installer/tests/Unit/Schema/SchemaGeneratorTest.php
  • .vortex/tests/phpunit/Functional/AhoyWorkflowTest.php
  • .vortex/tests/phpunit/Traits/Subtests/SubtestAhoyTrait.php
  • docker-compose.yml

Comment on lines +30 to +37
public function placeholder(array $responses): ?string {
if (isset($responses[OrgMachineName::id()]) && isset($responses[MachineName::id()])
&& !empty($responses[OrgMachineName::id()]) && !empty($responses[MachineName::id()])) {
return sprintf('E.g. %s/%s-data-migration:latest',
strtolower(Converter::phpNamespace($responses[OrgMachineName::id()])),
strtolower(Converter::phpNamespace($responses[MachineName::id()]))
);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Extract shared migration-image template generation.

The placeholder and default paths duplicate the same formatting logic; consolidate into one helper to prevent drift.

Refactor sketch
 class MigrationImage extends AbstractHandler {
+  private function buildMigrationImage(array $responses): ?string {
+    if (
+      isset($responses[OrgMachineName::id()], $responses[MachineName::id()]) &&
+      !empty($responses[OrgMachineName::id()]) &&
+      !empty($responses[MachineName::id()])
+    ) {
+      return sprintf(
+        '%s/%s-data-migration:latest',
+        strtolower(Converter::phpNamespace($responses[OrgMachineName::id()])),
+        strtolower(Converter::phpNamespace($responses[MachineName::id()]))
+      );
+    }
+    return NULL;
+  }
+
   public function placeholder(array $responses): ?string {
-    if (isset($responses[OrgMachineName::id()]) && isset($responses[MachineName::id()])
-      && !empty($responses[OrgMachineName::id()]) && !empty($responses[MachineName::id()])) {
-      return sprintf('E.g. %s/%s-data-migration:latest',
-        strtolower(Converter::phpNamespace($responses[OrgMachineName::id()])),
-        strtolower(Converter::phpNamespace($responses[MachineName::id()]))
-      );
-    }
+    $image = $this->buildMigrationImage($responses);
+    if ($image !== NULL) {
+      return sprintf('E.g. %s', $image);
+    }
 
     return parent::placeholder($responses);
   }
 
   public function default(array $responses): null|string|bool|array {
-    if (
-      isset($responses[OrgMachineName::id()]) &&
-      isset($responses[MachineName::id()]) &&
-      !empty($responses[OrgMachineName::id()]) &&
-      !empty($responses[MachineName::id()])
-    ) {
-      return sprintf(
-        '%s/%s-data-migration:latest',
-        strtolower(Converter::phpNamespace($responses[OrgMachineName::id()])),
-        strtolower(Converter::phpNamespace($responses[MachineName::id()]))
-      );
-    }
-
-    return NULL;
+    return $this->buildMigrationImage($responses);
   }

Also applies to: 60-70

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.vortex/installer/src/Prompts/Handlers/MigrationImage.php around lines 30 -
37, Extract the duplicated migration-image formatting into a single helper
(e.g., a private static method like buildMigrationImageTemplate or
migrationImageTemplate) and update both placeholder(array $responses) and the
default-generating method (the one around lines 60-70) to call this helper; the
helper should accept the two inputs pulled from $responses using
OrgMachineName::id() and MachineName::id(), apply Converter::phpNamespace and
strtolower, and return the sprintf string ('E.g. %s/%s-data-migration:latest' or
the corresponding default value) so the formatting logic exists in one place and
both methods delegate to it.

);

$this->logSubstep('Reload database2 from the container image');
$this->cmd('ahoy reload-db2', txt: '`ahoy reload-db2` reloads migration database container', tio: 60);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Provide confirmation input for ahoy reload-db2 in test flow.

At Line 907, this command is interactive. Without explicit input, the subtest can hang or timeout in non-interactive contexts.

💡 Proposed fix
-    $this->cmd('ahoy reload-db2', txt: '`ahoy reload-db2` reloads migration database container', tio: 60);
+    $this->cmd('ahoy reload-db2', inp: ['y'], txt: '`ahoy reload-db2` reloads migration database container', tio: 60);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$this->cmd('ahoy reload-db2', txt: '`ahoy reload-db2` reloads migration database container', tio: 60);
$this->cmd('ahoy reload-db2', inp: ['y'], txt: '`ahoy reload-db2` reloads migration database container', tio: 60);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.vortex/tests/phpunit/Traits/Subtests/SubtestAhoyTrait.php at line 907, The
interactive call $this->cmd('ahoy reload-db2', txt: '`ahoy reload-db2` reloads
migration database container', tio: 60) can hang in CI; update the
SubtestAhoyTrait to make this invocation non-interactive by supplying
confirmation input or an explicit non-interactive flag. Locate the $this->cmd
call for 'ahoy reload-db2' and either pass a confirmation input (e.g., simulate
"y\n" via the cmd helper's input parameter) or add the appropriate ahoy flag
(e.g., --yes/--force) so the command completes without prompting.

@github-actions

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

2 similar comments
@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk AlexSkrypnyk force-pushed the feature/2379-reload-db2 branch from 930c30a to 14f4f12 Compare March 25, 2026 08:09
@github-actions

This comment has been minimized.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docker-compose.yml (1)

201-213: ⚠️ Potential issue | 🟡 Minor

Replace --build flag with explicit docker compose pull in reload-db2 command.

The database2 service uses a direct image: directive without a build context, so the --build flag in the reload-db2 command has no effect (Docker Compose silently skips building image-only services). This differs from reload-db, which uses docker compose build database on a build-based service.

For proper image updates—especially with private registries—the command should explicitly pull the image:

docker compose pull database2

Either add this step before starting the container, or remove the ineffective --build flag.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docker-compose.yml` around lines 201 - 213, The reload-db2 task is using a
useless --build flag for the image-only service database2; update the reload-db2
command to explicitly pull the image before starting by running "docker compose
pull database2" (or remove the --build flag and add a separate "docker compose
pull database2" step) so the database2 image from the registry is refreshed;
locate the reload-db2 recipe that targets the database2 service and replace the
ineffective build behavior with an explicit pull of the database2 image.
♻️ Duplicate comments (4)
.vortex/installer/src/Prompts/Handlers/MigrationImage.php (1)

30-40: 🧹 Nitpick | 🔵 Trivial

Extract shared migration-image template generation.

The placeholder and default methods duplicate the same formatting logic for building the image name string. This was previously flagged and should be consolidated into a helper method to prevent drift.

♻️ Proposed refactor
 class MigrationImage extends AbstractHandler {
+
+  private function buildMigrationImage(array $responses): ?string {
+    if (
+      isset($responses[OrgMachineName::id()], $responses[MachineName::id()]) &&
+      !empty($responses[OrgMachineName::id()]) &&
+      !empty($responses[MachineName::id()])
+    ) {
+      return sprintf(
+        '%s/%s-data-migration:latest',
+        strtolower(Converter::phpNamespace($responses[OrgMachineName::id()])),
+        strtolower(Converter::phpNamespace($responses[MachineName::id()]))
+      );
+    }
+    return NULL;
+  }
 
   public function placeholder(array $responses): ?string {
-    if (isset($responses[OrgMachineName::id()]) && isset($responses[MachineName::id()])
-      && !empty($responses[OrgMachineName::id()]) && !empty($responses[MachineName::id()])) {
-      return sprintf('E.g. %s/%s-data-migration:latest',
-        strtolower(Converter::phpNamespace($responses[OrgMachineName::id()])),
-        strtolower(Converter::phpNamespace($responses[MachineName::id()]))
-      );
-    }
-
-    return parent::placeholder($responses);
+    $image = $this->buildMigrationImage($responses);
+    return $image !== NULL ? sprintf('E.g. %s', $image) : parent::placeholder($responses);
   }
 
   public function default(array $responses): null|string|bool|array {
-    if (
-      isset($responses[OrgMachineName::id()]) &&
-      isset($responses[MachineName::id()]) &&
-      !empty($responses[OrgMachineName::id()]) &&
-      !empty($responses[MachineName::id()])
-    ) {
-      return sprintf(
-        '%s/%s-data-migration:latest',
-        strtolower(Converter::phpNamespace($responses[OrgMachineName::id()])),
-        strtolower(Converter::phpNamespace($responses[MachineName::id()]))
-      );
-    }
-
-    return NULL;
+    return $this->buildMigrationImage($responses);
   }

Also applies to: 59-74

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.vortex/installer/src/Prompts/Handlers/MigrationImage.php around lines 30 -
40, The placeholder and default methods in MigrationImage duplicate the same
image-name formatting logic; extract that logic into a single private helper
(e.g., buildMigrationImageTemplate or formatMigrationImage) and have both
placeholder(array $responses) and default(array $responses) call it; the helper
should accept the $responses array, check OrgMachineName::id() and
MachineName::id() presence/emptiness, call Converter::phpNamespace and
strtolower to produce the "%s/%s-data-migration:latest" string, and fall back to
parent::placeholder($responses) or parent::default($responses) when inputs are
missing.
.vortex/tests/phpunit/Traits/Subtests/SubtestAhoyTrait.php (1)

907-907: ⚠️ Potential issue | 🟠 Major

Provide confirmation input for ahoy reload-db2 in test flow.

The ahoy reload-db2 command prompts for confirmation. Without explicit input, this test could hang or timeout in non-interactive CI contexts.

🐛 Proposed fix
-    $this->cmd('ahoy reload-db2', txt: '`ahoy reload-db2` reloads migration database container', tio: 60);
+    $this->cmd('ahoy reload-db2', inp: ['y'], txt: '`ahoy reload-db2` reloads migration database container', tio: 60);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.vortex/tests/phpunit/Traits/Subtests/SubtestAhoyTrait.php at line 907, The
test invokes an interactive command that prompts for confirmation but doesn't
supply input, causing CI hangs; update the $this->cmd call for 'ahoy reload-db2'
to provide the confirmation input (e.g., send "y\n" or "yes\n") so the prompt is
answered non-interactively, for example by adding the appropriate input/stdin
parameter to the existing $this->cmd('ahoy reload-db2', txt: '`ahoy reload-db2`
reloads migration database container', tio: 60) call in the SubtestAhoyTrait.
.vortex/tests/phpunit/Functional/AhoyWorkflowTest.php (1)

309-311: ⚠️ Potential issue | 🟡 Minor

Add explicit migration source assertion for end-to-end validation.

At Line 310, the test verifies image value, but it should also verify that .env selected the container_registry source path.

Suggested patch
     $this->logSubstep('Verify migration database image configuration');
+    $this->assertFileContainsString('.env', 'VORTEX_DOWNLOAD_DB2_SOURCE=container_registry', '.env should contain migration download source');
     $this->assertFileContainsString('.env', 'VORTEX_DB2_IMAGE=' . self::VORTEX_DB_IMAGE_TEST, '.env should contain migration database image');
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.vortex/tests/phpunit/Functional/AhoyWorkflowTest.php around lines 309 -
311, The test currently checks only the migration DB image value using
assertFileContainsString in
AhoyWorkflowTest::logSubstep/assertFileContainsString; add an explicit assertion
that the .env also contains the migration source path key set to
container_registry (e.g. verify presence of
"VORTEX_DB2_SOURCE=container_registry") using the same assertFileContainsString
helper so the end-to-end test validates both image and source selection.
.ahoy.yml (1)

166-166: ⚠️ Potential issue | 🟡 Minor

Clarify the confirmation prompt target.

Line 166 should explicitly mention the migration database to avoid ambiguity for reload-db2.

Suggested patch
-      ahoy confirm "Running this command will replace your current database. Are you sure?" || exit 0
+      ahoy confirm "Running this command will replace your current migration database. Are you sure?" || exit 0
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.ahoy.yml at line 166, Update the confirmation prompt invoked by ahoy (the
ahoy confirm call) to explicitly reference the migration database being replaced
(e.g., mention "migration database" or the specific DB name) so that the
reload-db2 command’s intention is unambiguous; edit the string passed to ahoy
confirm to include that explicit target (and any variable like MIGRATION_DB if
used) so users know reload-db2 will replace the migration database.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@docker-compose.yml`:
- Around line 201-213: The reload-db2 task is using a useless --build flag for
the image-only service database2; update the reload-db2 command to explicitly
pull the image before starting by running "docker compose pull database2" (or
remove the --build flag and add a separate "docker compose pull database2" step)
so the database2 image from the registry is refreshed; locate the reload-db2
recipe that targets the database2 service and replace the ineffective build
behavior with an explicit pull of the database2 image.

---

Duplicate comments:
In @.ahoy.yml:
- Line 166: Update the confirmation prompt invoked by ahoy (the ahoy confirm
call) to explicitly reference the migration database being replaced (e.g.,
mention "migration database" or the specific DB name) so that the reload-db2
command’s intention is unambiguous; edit the string passed to ahoy confirm to
include that explicit target (and any variable like MIGRATION_DB if used) so
users know reload-db2 will replace the migration database.

In @.vortex/installer/src/Prompts/Handlers/MigrationImage.php:
- Around line 30-40: The placeholder and default methods in MigrationImage
duplicate the same image-name formatting logic; extract that logic into a single
private helper (e.g., buildMigrationImageTemplate or formatMigrationImage) and
have both placeholder(array $responses) and default(array $responses) call it;
the helper should accept the $responses array, check OrgMachineName::id() and
MachineName::id() presence/emptiness, call Converter::phpNamespace and
strtolower to produce the "%s/%s-data-migration:latest" string, and fall back to
parent::placeholder($responses) or parent::default($responses) when inputs are
missing.

In @.vortex/tests/phpunit/Functional/AhoyWorkflowTest.php:
- Around line 309-311: The test currently checks only the migration DB image
value using assertFileContainsString in
AhoyWorkflowTest::logSubstep/assertFileContainsString; add an explicit assertion
that the .env also contains the migration source path key set to
container_registry (e.g. verify presence of
"VORTEX_DB2_SOURCE=container_registry") using the same assertFileContainsString
helper so the end-to-end test validates both image and source selection.

In @.vortex/tests/phpunit/Traits/Subtests/SubtestAhoyTrait.php:
- Line 907: The test invokes an interactive command that prompts for
confirmation but doesn't supply input, causing CI hangs; update the $this->cmd
call for 'ahoy reload-db2' to provide the confirmation input (e.g., send "y\n"
or "yes\n") so the prompt is answered non-interactively, for example by adding
the appropriate input/stdin parameter to the existing $this->cmd('ahoy
reload-db2', txt: '`ahoy reload-db2` reloads migration database container', tio:
60) call in the SubtestAhoyTrait.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 78c79bdc-8772-411c-b0aa-9f3d0f7fb842

📥 Commits

Reviewing files that changed from the base of the PR and between 930c30a and 14f4f12.

⛔ Files ignored due to path filters (30)
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_acquia/.ahoy.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_acquia/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/.ahoy.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/.env is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/.github/workflows/build-test-deploy.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/.gitignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/composer.json is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/scripts/custom/provision-20-migration.sh is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/tests/phpunit/Drupal/DatabaseSettingsTest.php is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/tests/phpunit/Drupal/EnvironmentSettingsTest.php is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/tests/phpunit/Drupal/SettingsTestCase.php is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/web/modules/custom/ys_migrate/migrations/ys_migrate_categories.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/web/modules/custom/ys_migrate/ys_migrate.info.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/web/sites/default/settings.migration.php is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_container_registry/web/sites/default/settings.php is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_ftp/.ahoy.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_ftp/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_lagoon/.ahoy.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_lagoon/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_s3/.ahoy.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_s3/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_url/.ahoy.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_download_source_url/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_enabled/.ahoy.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_enabled/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.ahoy.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_enabled_lagoon/.ahoy.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_enabled_lagoon/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
📒 Files selected for processing (13)
  • .ahoy.yml
  • .env
  • .vortex/installer/src/Prompts/Handlers/MigrationDownloadSource.php
  • .vortex/installer/src/Prompts/Handlers/MigrationImage.php
  • .vortex/installer/src/Prompts/PromptManager.php
  • .vortex/installer/tests/Functional/Handlers/MigrationDownloadSourceHandlerProcessTest.php
  • .vortex/installer/tests/Unit/Handlers/AbstractHandlerDiscoveryTestCase.php
  • .vortex/installer/tests/Unit/Handlers/AbstractHandlerTypeTest.php
  • .vortex/installer/tests/Unit/Handlers/MigrationImageHandlerDiscoveryTest.php
  • .vortex/installer/tests/Unit/Schema/SchemaGeneratorTest.php
  • .vortex/tests/phpunit/Functional/AhoyWorkflowTest.php
  • .vortex/tests/phpunit/Traits/Subtests/SubtestAhoyTrait.php
  • docker-compose.yml

@AlexSkrypnyk

This comment has been minimized.

2 similar comments
@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

@github-actions

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

1 similar comment
@AlexSkrypnyk

This comment has been minimized.

@github-actions

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

2 similar comments
@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

@github-actions

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

2 similar comments
@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

@github-actions

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

2 similar comments
@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

@github-actions
Copy link
Copy Markdown

Code coverage (threshold: 90%)

  Classes: 100.00% (1/1)
  Methods: 100.00% (2/2)
  Lines:   100.00% (189/189)
Per-class coverage
Drupal\ys_demo\Plugin\Block\CounterBlock
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 10/ 10)

@AlexSkrypnyk

This comment has been minimized.

2 similar comments
@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk
Copy link
Copy Markdown
Member Author

Code coverage (threshold: 90%)

  Classes: 100.00% (1/1)
  Methods: 100.00% (2/2)
  Lines:   100.00% (189/189)
Per-class coverage
Drupal\ys_demo\Plugin\Block\CounterBlock
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 10/ 10)

@AlexSkrypnyk AlexSkrypnyk merged commit 880d1eb into main Mar 25, 2026
30 checks passed
@AlexSkrypnyk AlexSkrypnyk deleted the feature/2379-reload-db2 branch March 25, 2026 12:08
@github-project-automation github-project-automation bot moved this from BACKLOG to Release queue in Vortex Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Release queue

Development

Successfully merging this pull request may close these issues.

Add reload-db2 for migration DB in container image

1 participant