Skip to content

Commit 360a319

Browse files
committed
[#1642] Added support for migration DB.
1 parent 0b084ea commit 360a319

129 files changed

Lines changed: 5524 additions & 211 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.ahoy.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ commands:
3535
cmd: |
3636
COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME:-${PWD##*/}} \
3737
VORTEX_HOST_DB_PORT=$(docker compose port database 3306 2>/dev/null | cut -d : -f 2) \
38+
#;< MIGRATION
39+
VORTEX_HOST_DB2_PORT=$(docker compose port database2 3306 2>/dev/null | cut -d : -f 2) \
40+
#;> MIGRATION
3841
VORTEX_HOST_SOLR_PORT=$(docker compose port solr 8983 2>/dev/null | cut -d : -f 2) \
3942
VORTEX_HOST_SELENIUM_VNC_PORT=$(docker compose port chrome 7900 2>/dev/null | cut -d : -f 2) \
4043
VORTEX_HOST_HAS_SEQUELACE=$(uname -a | grep -i -q darwin && mdfind -name 'Sequel Ace' 2>/dev/null | grep -q "Ace" && echo 1 || true) \
@@ -48,6 +51,16 @@ commands:
4851
open "mysql://${DATABASE_USERNAME:-drupal}:${DATABASE_PASSWORD:-drupal}@127.0.0.1:${VORTEX_HOST_DB_PORT}/drupal" -a "Sequel Ace" \
4952
|| echo "Not a supported OS or Sequel Ace is not installed."
5053
54+
#;< MIGRATION
55+
db2:
56+
usage: Open DB2 in Sequel Ace.
57+
cmd: |
58+
uname -a | grep -i -q darwin && test -d "${VORTEX_HOST_SEQUELACE_PATH:-/Applications/Sequel Ace.app}" && \
59+
VORTEX_HOST_DB2_PORT=$(docker compose port database2 3306 2>/dev/null | cut -d : -f 2) && \
60+
open "mysql://${DATABASE2_USERNAME:-drupal}:${DATABASE2_PASSWORD:-drupal}@127.0.0.1:${VORTEX_HOST_DB2_PORT}/drupal" -a "Sequel Ace" \
61+
|| echo "Not a supported OS or Sequel Ace is not installed."
62+
#;> MIGRATION
63+
5164
# ----------------------------------------------------------------------------
5265
# Container commands.
5366
# ----------------------------------------------------------------------------
@@ -125,6 +138,15 @@ commands:
125138
cmd: |
126139
case " $* " in *" --fresh "*) export VORTEX_DOWNLOAD_DB_FRESH=1;; esac
127140
./scripts/vortex/download-db.sh
141+
142+
#;< MIGRATION
143+
download-db2:
144+
usage: Download second database (migration). Run with "--fresh" to force.
145+
aliases: [fetch-db2]
146+
cmd: |
147+
case " $* " in *" --fresh "*) export VORTEX_DOWNLOAD_DB_FORCE=1;; esac
148+
VORTEX_VAR_PREFIX=VORTEX_DOWNLOAD_DB2 ./scripts/vortex/download-db.sh
149+
#;> MIGRATION
128150
#;> !PROVISION_TYPE_PROFILE
129151

130152
reload-db:

.circleci/config.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,23 @@ jobs:
154154
# Change 'v1' to 'v2', 'v3' etc., commit and push to force cache reset.
155155
# Lookup cache based on the default branch and a timestamp. Allows
156156
# to use cache from the very first build on the day (sanitized database dump, for example).
157-
- v26.1.0-db11-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback" }}-{{ checksum "/tmp/db_cache_timestamp" }}
157+
- v26.2.0-db11-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback" }}-{{ checksum "/tmp/db_cache_timestamp" }}
158158
# Fallback to caching by default branch name only. Allows to use
159159
# cache from the branch build on the previous day.
160-
- v26.1.0-db11-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback" }}-
160+
- v26.2.0-db11-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback" }}-
161161

162162
- run:
163163
name: Download DB
164164
command: VORTEX_DOWNLOAD_DB_SEMAPHORE=/tmp/download-db-success ./scripts/vortex/download-db.sh
165165
no_output_timeout: 30m
166166

167+
#;< MIGRATION
168+
- run:
169+
name: Download migration DB
170+
command: VORTEX_VAR_PREFIX=VORTEX_DOWNLOAD_DB2 ./scripts/vortex/download-db.sh
171+
no_output_timeout: 30m
172+
#;> MIGRATION
173+
167174
# Execute commands after database download script finished: if the
168175
# DB dump was downloaded - build the site (to ensure that the DB dump
169176
# is valid) and export the DB using selected method (to support
@@ -187,7 +194,7 @@ jobs:
187194
# The cache will not be saved if it already exists.
188195
# Note that the cache fallback flag is enabled for this case in order
189196
# to save cache even if the fallback is not used when restoring it.
190-
key: v26.1.0-db11-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }}
197+
key: v26.2.0-db11-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }}
191198
paths:
192199
- /root/project/.data
193200

@@ -236,8 +243,8 @@ jobs:
236243
keys:
237244
# Use cached artifacts from previous builds of this branch.
238245
# https://circleci.com/docs/2.0/caching/#restoring-cache
239-
- v26.1.0-db11-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }}
240-
- v26.1.0-db11-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-
246+
- v26.2.0-db11-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }}
247+
- v26.2.0-db11-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-
241248
#;> !PROVISION_TYPE_PROFILE
242249

243250
- *step_setup_remote_docker
@@ -356,6 +363,11 @@ jobs:
356363
if [ -f .data/db.sql ]; then
357364
docker compose exec cli mkdir -p .data
358365
docker compose cp -L .data/db.sql cli:/app/.data/db.sql
366+
#;< MIGRATION
367+
if [ -f ".data/${VORTEX_DOWNLOAD_DB2_FILE:-db2.sql}" ]; then
368+
docker compose cp -L ".data/${VORTEX_DOWNLOAD_DB2_FILE:-db2.sql}" cli:"/app/.data/${VORTEX_DOWNLOAD_DB2_FILE:-db2.sql}"
369+
fi
370+
#;> MIGRATION
359371
fi
360372
docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli ./scripts/vortex/provision.sh
361373
no_output_timeout: 30m

.env

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,61 @@ VORTEX_DOWNLOAD_DB_ACQUIA_DB_NAME=your_site
226226

227227
#;> !PROVISION_TYPE_PROFILE
228228

229+
#;< MIGRATION
230+
################################################################################
231+
# SECOND DATABASE (MIGRATION) #
232+
################################################################################
233+
234+
# Second database for migrations.
235+
# See settings.migration.php for database credentials.
236+
237+
# Second database dump file name.
238+
VORTEX_DOWNLOAD_DB2_FILE=db2.sql
239+
240+
# Second database download source.
241+
VORTEX_DOWNLOAD_DB2_SOURCE=url
242+
243+
#;< MIGRATION_DB_DOWNLOAD_SOURCE_URL
244+
# Second database dump file sourced from a URL.
245+
#
246+
# HTTP Basic Authentication credentials should be embedded into the value.
247+
VORTEX_DOWNLOAD_DB2_URL=
248+
#;> MIGRATION_DB_DOWNLOAD_SOURCE_URL
249+
250+
#;< MIGRATION_DB_DOWNLOAD_SOURCE_FTP
251+
# Second database dump file sourced from FTP.
252+
253+
# Second database dump FTP host.
254+
VORTEX_DOWNLOAD_DB2_FTP_HOST=
255+
256+
# Second database dump FTP port.
257+
VORTEX_DOWNLOAD_DB2_FTP_PORT=21
258+
259+
# Second database dump FTP file name.
260+
VORTEX_DOWNLOAD_DB2_FTP_FILE=db2.sql
261+
#;> MIGRATION_DB_DOWNLOAD_SOURCE_FTP
262+
263+
#;< MIGRATION_DB_DOWNLOAD_SOURCE_S3
264+
# Second database dump file sourced from S3.
265+
266+
# AWS S3 bucket name for second database download.
267+
VORTEX_DOWNLOAD_DB2_S3_BUCKET=
268+
269+
# AWS S3 region.
270+
VORTEX_DOWNLOAD_DB2_S3_REGION=ap-southeast-2
271+
#;> MIGRATION_DB_DOWNLOAD_SOURCE_S3
272+
273+
# Environment to download the second database from.
274+
#
275+
# Applies to hosting environments.
276+
VORTEX_DOWNLOAD_DB2_ENVIRONMENT=prod
277+
278+
#;< HOSTING_ACQUIA
279+
# Acquia database name to download the second database from.
280+
VORTEX_DOWNLOAD_DB2_ACQUIA_DB_NAME=your_site
281+
#;> HOSTING_ACQUIA
282+
#;> MIGRATION
283+
229284
################################################################################
230285
# RELEASE VERSIONING #
231286
################################################################################
@@ -303,6 +358,13 @@ VORTEX_NOTIFY_WEBHOOK_URL=
303358
VORTEX_DOWNLOAD_DB_URL=https://github.com/drevops/vortex/releases/download/25.4.0/db_d11.demo.sql
304359
#;> DB_DOWNLOAD_SOURCE_URL
305360

361+
#;< MIGRATION
362+
#;< MIGRATION_DB_DOWNLOAD_SOURCE_URL
363+
# URL of the migration source database used for demonstration.
364+
VORTEX_DOWNLOAD_DB2_URL=https://github.com/drevops/vortex/releases/download/25.4.0/db_d11.demo_source.sql
365+
#;> MIGRATION_DB_DOWNLOAD_SOURCE_URL
366+
#;> MIGRATION
367+
306368
#;< DB_DOWNLOAD_SOURCE_CONTAINER_REGISTRY
307369
# Demo database container image used for demonstration of database-in-image
308370
# data storage.

.github/workflows/build-test-deploy.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ jobs:
122122
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5
123123
with:
124124
path: .data
125-
key: v26.1.0-db11-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback') }}-${{ hashFiles('db_cache_timestamp') }}
125+
key: v26.2.0-db11-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback') }}-${{ hashFiles('db_cache_timestamp') }}
126126
# Fallback to caching by default branch name only. Allows to use
127127
# cache from the branch build on the previous day.
128128
restore-keys: |
129-
v26.1.0-db11-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback') }}-
129+
v26.2.0-db11-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback') }}-
130130
131131
- name: Download DB
132132
run: |
@@ -139,6 +139,11 @@ jobs:
139139
VORTEX_ACQUIA_SECRET: ${{ secrets.VORTEX_ACQUIA_SECRET }}
140140
#;> DB_DOWNLOAD_SOURCE_ACQUIA
141141

142+
#;< MIGRATION
143+
- name: Download migration DB
144+
run: VORTEX_VAR_PREFIX=VORTEX_DOWNLOAD_DB2 ./scripts/vortex/download-db.sh
145+
#;> MIGRATION
146+
142147
- name: Export DB
143148
run: |
144149
if [ ! -f /tmp/download-db-success ]; then echo "==> Database download semaphore file is missing. DB export will not proceed."; exit 0; fi
@@ -158,7 +163,7 @@ jobs:
158163
if: env.db_hash != hashFiles('.data')
159164
with:
160165
path: .data
161-
key: v26.1.0-db11-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback_yes') }}-${{ hashFiles('db_cache_timestamp') }}
166+
key: v26.2.0-db11-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback_yes') }}-${{ hashFiles('db_cache_timestamp') }}
162167
#;> !PROVISION_TYPE_PROFILE
163168

164169
build:
@@ -223,7 +228,7 @@ jobs:
223228
date "${VORTEX_CI_DB_CACHE_TIMESTAMP}" | tee db_cache_timestamp
224229
225230
- name: Show cache key for database caching
226-
run: echo 'v26.1.0-db11-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback_yes') }}-${{ hashFiles('db_cache_timestamp') }}'
231+
run: echo 'v26.2.0-db11-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback_yes') }}-${{ hashFiles('db_cache_timestamp') }}'
227232

228233
# Restore DB cache based on the cache strategy set by the cache keys below.
229234
# Change 'v1' to 'v2', 'v3' etc., commit and push to force cache reset.
@@ -235,9 +240,9 @@ jobs:
235240
path: .data
236241
fail-on-cache-miss: true
237242
# Use cached database from previous builds of this branch.
238-
key: v26.1.0-db11-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback_yes') }}-${{ hashFiles('db_cache_timestamp') }}
243+
key: v26.2.0-db11-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback_yes') }}-${{ hashFiles('db_cache_timestamp') }}
239244
restore-keys: |
240-
v26.1.0-db11-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback_yes') }}-
245+
v26.2.0-db11-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback_yes') }}-
241246
#;> !PROVISION_TYPE_PROFILE
242247

243248
- name: Login to container registry
@@ -340,6 +345,11 @@ jobs:
340345
if [ -f .data/db.sql ]; then
341346
docker compose exec cli mkdir -p .data
342347
docker compose cp -L .data/db.sql cli:/app/.data/db.sql
348+
#;< MIGRATION
349+
if [ -f ".data/${VORTEX_DOWNLOAD_DB2_FILE:-db2.sql}" ]; then
350+
docker compose cp -L ".data/${VORTEX_DOWNLOAD_DB2_FILE:-db2.sql}" cli:"/app/.data/${VORTEX_DOWNLOAD_DB2_FILE:-db2.sql}"
351+
fi
352+
#;> MIGRATION
343353
fi
344354
docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli ./scripts/vortex/provision.sh
345355
timeout-minutes: 30

.github/workflows/vortex-test-common.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,5 +237,5 @@ jobs:
237237
continue-on-error: ${{ vars.VORTEX_CI_YAMLLINT_IGNORE_FAILURE == '1' }}
238238

239239
- name: Check coding standards with actionlint
240-
run: docker run --rm -v "${GITHUB_WORKSPACE:-.}":/app --workdir /app rhysd/actionlint:1.7.2 -ignore 'SC2002:' -ignore 'SC2155:' -ignore 'SC2015:' -ignore 'SC2046:' -ignore 'SC1090:'
240+
run: docker run --rm -v "${GITHUB_WORKSPACE:-.}":/app --workdir /app rhysd/actionlint:1.7.10 -ignore 'SC2002:' -ignore 'SC2155:' -ignore 'SC2015:' -ignore 'SC2046:' -ignore 'SC1090:'
241241
continue-on-error: ${{ vars.VORTEX_CI_ACTIONLINT_IGNORE_FAILURE == '1' }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ web/profiles/*
2323
web/sites/default/*
2424
!web/sites/default/settings.php
2525
!web/sites/default/services.yml
26+
#;< MIGRATION
27+
!web/sites/default/settings.migration.php
28+
#;> MIGRATION
2629
!web/sites/default/example.settings.local.php
2730
!web/sites/default/example.services.local.yml
2831
!web/sites/default/default.settings.local.php

.lagoon.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ tasks:
6161
service: cli
6262
#;> !PROVISION_TYPE_PROFILE
6363

64+
#;< MIGRATION
65+
- run:
66+
name: Download migration database
67+
command: |
68+
export VORTEX_DOWNLOAD_DB_SSH_FILE=false
69+
export VORTEX_DB_DIR=/tmp/data
70+
VORTEX_VAR_PREFIX=VORTEX_DOWNLOAD_DB2 ./scripts/vortex/download-db.sh
71+
service: cli
72+
#;> MIGRATION
73+
6474
- run:
6575
name: Provision site
6676
command: |
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
##
3+
# Create migration source database with sample data.
4+
#
5+
# This script populates the migration source database with a `categories` table
6+
# containing sample data for demonstration purposes.
7+
#
8+
# Usage:
9+
# DB_URL=mysql://user:pass@host:port/dbname ./create-migrate-source-db.sh
10+
#
11+
# Or using drush:
12+
# $(drush sql:connect) < <(./create-migrate-source-db.sh --sql)
13+
14+
set -eu
15+
[ "${VORTEX_DEBUG-}" = "1" ] && set -x
16+
17+
sql=$(
18+
cat <<'SQL'
19+
DROP TABLE IF EXISTS `categories`;
20+
21+
CREATE TABLE `categories` (
22+
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
23+
`name` varchar(255) NOT NULL,
24+
`description` text DEFAULT NULL,
25+
PRIMARY KEY (`id`)
26+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
27+
28+
INSERT INTO `categories` (`id`, `name`, `description`) VALUES
29+
(1, 'Jedi Order', 'Ancient order of Force-sensitive protectors of peace and justice in the galaxy.'),
30+
(2, 'Sith Lords', 'Dark side practitioners who seek power and dominion over the galaxy.'),
31+
(3, 'Galactic Empire', 'Authoritarian government that ruled the galaxy through fear and military might.'),
32+
(4, 'Rebel Alliance', 'Coalition of resistance fighters opposing the tyranny of the Galactic Empire.'),
33+
(5, 'Bounty Hunters', 'Mercenaries and trackers who pursue targets for credits across the galaxy.'),
34+
(6, 'Smugglers', 'Independent pilots and traders who operate outside the law for profit.'),
35+
(7, 'Droids', 'Mechanical beings serving various roles from protocol to astromech duties.'),
36+
(8, 'Mandalorians', 'Warrior culture known for their beskar armor and combat traditions.'),
37+
(9, 'Wookiees', 'Tall, fur-covered species from Kashyyyk known for their strength and loyalty.'),
38+
(10, 'Hutts', 'Powerful crime lords who control vast criminal enterprises across the Outer Rim.');
39+
SQL
40+
)
41+
42+
if [ "${1:-}" = "--sql" ]; then
43+
printf '%s\n' "${sql}"
44+
exit 0
45+
fi
46+
47+
echo "${sql}"

0 commit comments

Comments
 (0)