-
-
Save cagartner/853108e15ac6fd346e4c6d7ba54afd6c to your computer and use it in GitHub Desktop.
Easily update, import and sanitize magento2 cloud databases
This file contains 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
function m2-update-database() { | |
# USAGE | |
# m2-update-database 'Magento Cloud Project Title' 'http://project.dev/' | |
# $1 = Project Title | |
# $2 = Local URL | |
# Get the project ID by the project title | |
PROJECT_ID=$(magento-cloud project:list --title=$1 --pipe) | |
GIT_BRANCH_NAME=$(git branch | grep \* | cut -d ' ' -f2) | |
# Dump the DB | |
magento-cloud db:dump --project=$PROJECT_ID --environment=$GIT_BRANCH_NAME -f dump.sql | |
# Import the DB | |
php bin/n98-magerun2 db:import dump.sql | |
# Sanitize the DB | |
php bin/n98-magerun2 config:set web/unsecure/base_url $2 | |
php bin/n98-magerun2 config:set web/secure/base_url $2 | |
php bin/n98-magerun2 config:delete web/unsecure/base_media_url | |
php bin/n98-magerun2 config:delete web/secure/base_media_url | |
php bin/n98-magerun2 config:set dev/css/merge_css_files 0 | |
php bin/n98-magerun2 config:set dev/css/minify_files 0 | |
php bin/n98-magerun2 config:set dev/js/merge_files 0 | |
php bin/n98-magerun2 config:set dev/js/minify_files 0 | |
php bin/n98-magerun2 config:delete dev/static/sign | |
php bin/n98-magerun2 config:delete catalog/search/engine | |
php bin/n98-magerun2 config:delete web/unsecure/base_static_url | |
php bin/n98-magerun2 config:delete web/secure/base_static_url | |
php bin/n98-magerun2 config:set web/secure/use_in_frontend 0 | |
php bin/n98-magerun2 config:set web/secure/use_in_adminhtml 0 | |
php bin/n98-magerun2 config:delete web/cookie/cookie_domain --all | |
# Delete the dumped database | |
rm dump.sql | |
php bin/n98-magerun2 cache:flush | |
php bin/n98-magerun2 indexer:reindex | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment