-
-
Notifications
You must be signed in to change notification settings - Fork 28
[#2379] Added 'reload-db2' ahoy command for migration database container. #2421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
14f4f12
[#2379] Added container registry support for migration database image.
AlexSkrypnyk 2846e13
[#2379] Updated installer video with migration container registry opt…
AlexSkrypnyk 7a07eee
[#2379] Added assertion for migration download source in functional t…
AlexSkrypnyk bd3d814
[#2379] Skipped migration during build in container image test.
AlexSkrypnyk fa9711a
[#2379] Fixed drush argument passing through ahoy with '--' separator.
AlexSkrypnyk 5b32293
[#2379] Used 'ahoy cli' for drush commands with '--database' option.
AlexSkrypnyk 96bdee4
[#2379] Added wait for database2 readiness after container reload.
AlexSkrypnyk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
109 changes: 109 additions & 0 deletions
109
.vortex/installer/src/Prompts/Handlers/MigrationImage.php
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace DrevOps\VortexInstaller\Prompts\Handlers; | ||
|
|
||
| use DrevOps\VortexInstaller\Utils\Converter; | ||
| use DrevOps\VortexInstaller\Utils\Env; | ||
| use DrevOps\VortexInstaller\Utils\Validator; | ||
|
|
||
| class MigrationImage extends AbstractHandler { | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function label(): string { | ||
| return 'What is your migration database container image name and a tag?'; | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function hint(array $responses): ?string { | ||
| return 'Use "latest" tag for the latest version. CI will be building this image overnight.'; | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| 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()])) | ||
| ); | ||
| } | ||
|
Comment on lines
+30
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
|
||
| return parent::placeholder($responses); | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function dependsOn(): ?array { | ||
| return [MigrationDownloadSource::id() => [MigrationDownloadSource::CONTAINER_REGISTRY]]; | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function shouldRun(array $responses): bool { | ||
| return isset($responses[MigrationDownloadSource::id()]) && $responses[MigrationDownloadSource::id()] === MigrationDownloadSource::CONTAINER_REGISTRY; | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| 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; | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function discover(): null|string|bool|array { | ||
| return Env::getFromDotenv('VORTEX_DB2_IMAGE', $this->dstDir); | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function validate(): ?callable { | ||
| return fn($v): ?string => Validator::containerImage($v) ? NULL : 'Please enter a valid container image name with an optional tag.'; | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function transform(): ?callable { | ||
| return fn($v): string => trim((string) $v); | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function process(): void { | ||
| if (!empty($this->response)) { | ||
| $v = $this->getResponseAsString(); | ||
| $t = $this->tmpDir; | ||
|
|
||
| Env::writeValueDotenv('VORTEX_DB2_IMAGE', $v, $t . '/.env'); | ||
| } | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
51 changes: 51 additions & 0 deletions
51
...ler/tests/Fixtures/handler_process/migration_download_source_container_registry/.ahoy.yml
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| @@ -30,6 +30,7 @@ | ||
| cmd: | | ||
| export COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME:-${PWD##*/}} | ||
| export VORTEX_HOST_DB_PORT=$(docker compose port database 3306 2>/dev/null | cut -d : -f 2) | ||
| + export VORTEX_HOST_DB2_PORT=$(docker compose port database2 3306 2>/dev/null | cut -d : -f 2) | ||
| export VORTEX_HOST_SOLR_PORT=$(docker compose port solr 8983 2>/dev/null | cut -d : -f 2) | ||
| export VORTEX_HOST_SELENIUM_VNC_PORT=$(docker compose port chrome 7900 2>/dev/null | cut -d : -f 2) | ||
| export VORTEX_HOST_HAS_SEQUELACE=$(uname -a | grep -i -q darwin && mdfind -name 'Sequel Ace' 2>/dev/null | grep -q "Ace" && echo 1 || true) | ||
| @@ -43,6 +44,14 @@ | ||
| open "mysql://${DATABASE_USERNAME:-drupal}:${DATABASE_PASSWORD:-drupal}@127.0.0.1:${VORTEX_HOST_DB_PORT}/drupal" -a "Sequel Ace" \ | ||
| || echo "Not a supported OS or Sequel Ace is not installed." | ||
|
|
||
| + db2: | ||
| + usage: Open DB2 in Sequel Ace. | ||
| + cmd: | | ||
| + uname -a | grep -i -q darwin && test -d "${VORTEX_HOST_SEQUELACE_PATH:-/Applications/Sequel Ace.app}" && \ | ||
| + VORTEX_HOST_DB2_PORT=$(docker compose port database2 3306 2>/dev/null | cut -d : -f 2) && \ | ||
| + open "mysql://${DATABASE2_USERNAME:-drupal}:${DATABASE2_PASSWORD:-drupal}@127.0.0.1:${VORTEX_HOST_DB2_PORT}/drupal" -a "Sequel Ace" \ | ||
| + || echo "Not a supported OS or Sequel Ace is not installed." | ||
| + | ||
| # ---------------------------------------------------------------------------- | ||
| # Container commands. | ||
| # ---------------------------------------------------------------------------- | ||
| @@ -118,6 +127,13 @@ | ||
| case " $* " in *" --fresh "*) export VORTEX_DOWNLOAD_DB_FRESH=1;; esac | ||
| ./scripts/vortex/download-db.sh | ||
|
|
||
| + download-db2: | ||
| + usage: Download second database (migration). Run with "--fresh" to force. | ||
| + aliases: [fetch-db2] | ||
| + cmd: | | ||
| + case " $* " in *" --fresh "*) export VORTEX_DOWNLOAD_DB_FORCE=1;; esac | ||
| + VORTEX_DB_INDEX=2 ./scripts/vortex/download-db.sh | ||
| + | ||
| reload-db: | ||
| usage: Reload the database container using local database image. | ||
| cmd: | | ||
| @@ -125,6 +141,13 @@ | ||
| docker compose rm --force --stop --volumes database | ||
| docker compose build database | ||
| ahoy up | ||
| + | ||
| + reload-db2: | ||
| + usage: Reload the migration database container using local database image. | ||
| + cmd: | | ||
| + 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 | ||
|
|
||
| provision: | ||
| usage: Provision a site from the database dump or profile. |
29 changes: 29 additions & 0 deletions
29
...nstaller/tests/Fixtures/handler_process/migration_download_source_container_registry/.env
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| @@ -170,6 +170,28 @@ | ||
| VORTEX_DOWNLOAD_DB_ENVIRONMENT=prod | ||
|
|
||
| ################################################################################ | ||
| +# SECOND DATABASE (MIGRATION) # | ||
| +################################################################################ | ||
| + | ||
| +# Second database for migrations. | ||
| +# See settings.migration.php for database credentials. | ||
| + | ||
| +# Second database dump file name. | ||
| +VORTEX_DOWNLOAD_DB2_FILE=db2.sql | ||
| + | ||
| +# Second database download source. | ||
| +VORTEX_DOWNLOAD_DB2_SOURCE=container_registry | ||
| + | ||
| +# Name of the pre-built migration database container image. | ||
| +# @see https://github.com/drevops/mariadb-drupal-data to seed your DB image. | ||
| +VORTEX_DB2_IMAGE=the_empire/star_wars-migration:latest | ||
| + | ||
| +# Environment to download the second database from. | ||
| +# | ||
| +# Applies to hosting environments. | ||
| +VORTEX_DOWNLOAD_DB2_ENVIRONMENT=prod | ||
| + | ||
| +################################################################################ | ||
| # RELEASE VERSIONING # | ||
| ################################################################################ | ||
|
|
21 changes: 21 additions & 0 deletions
21
...cess/migration_download_source_container_registry/.github/workflows/build-test-deploy.yml
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| @@ -250,6 +250,9 @@ | ||
| echo "db_hash=${{ hashFiles('.data') }}" >> "$GITHUB_ENV" | ||
| timeout-minutes: 30 | ||
|
|
||
| + - name: Download migration DB | ||
| + run: VORTEX_DB_INDEX=2 ./scripts/vortex/download-db.sh | ||
| + | ||
| - name: Export DB | ||
| run: | | ||
| if [ ! -f /tmp/download-db-success ]; then echo "==> Database download semaphore file is missing. DB export will not proceed."; exit 0; fi | ||
| @@ -373,6 +376,10 @@ | ||
| if [ -f .data/db.sql ]; then | ||
| docker compose exec cli mkdir -p .data | ||
| docker compose cp -L .data/db.sql cli:/app/.data/db.sql | ||
| + fi | ||
| + if [ -f ".data/${VORTEX_DOWNLOAD_DB2_FILE:-db2.sql}" ]; then | ||
| + docker compose exec -T cli mkdir -p .data | ||
| + docker compose cp -L ".data/${VORTEX_DOWNLOAD_DB2_FILE:-db2.sql}" cli:"/app/.data/${VORTEX_DOWNLOAD_DB2_FILE:-db2.sql}" | ||
| fi | ||
| docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli ./scripts/vortex/provision.sh | ||
| timeout-minutes: 30 |
8 changes: 8 additions & 0 deletions
8
...er/tests/Fixtures/handler_process/migration_download_source_container_registry/.gitignore
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| @@ -21,6 +21,7 @@ | ||
| web/sites/default/* | ||
| !web/sites/default/settings.php | ||
| !web/sites/default/services.yml | ||
| +!web/sites/default/settings.migration.php | ||
| !web/sites/default/example.settings.local.php | ||
| !web/sites/default/example.services.local.yml | ||
| !web/sites/default/default.settings.local.php |
9 changes: 9 additions & 0 deletions
9
...tests/Fixtures/handler_process/migration_download_source_container_registry/composer.json
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| @@ -17,6 +17,8 @@ | ||
| "drupal/drupal_helpers": "__VERSION__", | ||
| "drupal/environment_indicator": "__VERSION__", | ||
| "drupal/generated_content": "__VERSION__", | ||
| + "drupal/migrate_plus": "__VERSION__", | ||
| + "drupal/migrate_tools": "__VERSION__", | ||
| "drupal/pathauto": "__VERSION__", | ||
| "drupal/redirect": "__VERSION__", | ||
| "drupal/redis": "__VERSION__", |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: drevops/vortex
Length of output: 963
🏁 Script executed:
Repository: drevops/vortex
Length of output: 40
🏁 Script executed:
Repository: drevops/vortex
Length of output: 2770
🏁 Script executed:
Repository: drevops/vortex
Length of output: 40
🏁 Script executed:
Repository: drevops/vortex
Length of output: 1209
The
reload-db2command has two issues that should be corrected.Line 166 should explicitly mention the migration database in the confirmation prompt, and Line 168's
--buildflag is ineffective sincedatabase2(which usesimage: uselagoon/mysql-8.4:26.2.0) has nobuild:definition.Suggested fix
🤖 Prompt for AI Agents