-
Notifications
You must be signed in to change notification settings - Fork 2
Create migration script #1
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
Open
michielgerritsen
wants to merge
8
commits into
mage-os-lab:main
Choose a base branch
from
controlaltdelete-nl:test-migration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Create migration script #1
michielgerritsen
wants to merge
8
commits into
mage-os-lab:main
from
controlaltdelete-nl:test-migration
Conversation
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
Contributor
|
Nice! Maybe we can add code to handle the cache flush directly, and maybe also prompt if they want to run setup at the end. I wrote this recently to extract the redis connection info from Magento config to bash: get_env_config() {
local key_path=$1
php -r "
\$config = require 'app/etc/env.php';
\$keys = explode('.', '${key_path}');
\$value = \$config;
foreach (\$keys as \$key) {
if (isset(\$value[\$key])) {
\$value = \$value[\$key];
} else {
\$value = ''; break;
}
}
echo is_array(\$value) ? json_encode(\$value) : \$value;
" 2>/dev/null
}
build_redis_connection_string() {
local server=$1
local port=$2
local password=$3
local db=$4
local args=""
# Return early if both server and host are empty
if [ -z "${server}" ] && [ -z "${port}" ]; then
echo ""
return
fi
if [ -n "${port}" ] && [ "${port}" != "0" ]; then
args="-h ${server} -p ${port}"
else
args="-s ${server}"
fi
# Add password if present
[ -n "${password}" ] && args="${args} -a ${password}"
echo "${args} -n ${db}"
}
# Extract Redis connection info from build env.php
redisCacheServer=$(get_env_config "cache.frontend.default.backend_options.server")
redisCachePort=$(get_env_config "cache.frontend.default.backend_options.port")
redisCachePassword=$(get_env_config "cache.frontend.default.backend_options.password")
redisCacheDB=$(get_env_config "cache.frontend.default.backend_options.database")
redisCache=$(build_redis_connection_string "${redisCacheServer}" "${redisCachePort}" "${redisCachePassword}" "${redisCacheDB}")
# Flush file or redis cache
if [ -n "${redisCache}" ]
redis-cli ${redisCache} FLUSHDB
else
rm -rf var/cache/*
fi |
d3fc515 to
aeaabf7
Compare
aeaabf7 to
1fdee5b
Compare
Author
|
@rhoerr Nice one! I added that, and now we can run the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This removes the
composer.jsonvariant in favor of a bash script. The script does the following checks:If all checks pass, the migration is executed. After the migration is complete, it is instructed to destroy the Redis cache or the
var/cachefolder, and runbin/magento setup:upgrade. Composer show is also run so the user can accept the new Composer plugins that get installed.The whole migration is tested through GitHub Actions. A Magento environment is spun up, and the migration is executed. After the migration, the installation is checked with an end-to-end test to verify that we can log in to the backend and that we see the Mage-OS footer notice. This is tested against 2.4.8 and the p1, p2, and p3 patch versions. I initially tried to add th e2.4.6 and 2.4.7 versions too but I've run into weird issues (setup:upgrade not defined, for example).