Skip to content

Instantly share code, notes, and snippets.

@sebastianrothbucher
Last active October 31, 2018 19:07
Show Gist options
  • Save sebastianrothbucher/45f8063d9b64b82300cfabf661e5820f to your computer and use it in GitHub Desktop.
Save sebastianrothbucher/45f8063d9b64b82300cfabf661e5820f to your computer and use it in GitHub Desktop.
Using db-migrate with Magento 2

Using db-migrate with Magento 2

Usage:

  1. Put all these files in magento/app/db (htaccess is in place then), go in that dir and npm install
  2. Create a new migration with a command à la export export DATABASE_URL=$(php dburl.php); node_modules/.bin/db-migrate create <<nameofmigration>> --sql-file
  3. Run main migration with npm run dbup or export DATABASE_URL="$(php dburl.php)?multipleStatements=true"; node_modules/.bin/db-migrate up
<?php
$cfg = include('../etc/env.php');
echo 'mysql://'.$cfg['db']['connection']['default']['username'].':'.$cfg['db']['connection']['default']['password'].'@'.$cfg['db']['connection']['default']['host'].'/'.$cfg['db']['connection']['default']['dbname']."\n";
{
"name": "db",
"version": "1.0.0",
"description": "",
"dependencies": {
"db-migrate": "^0.11.3",
"db-migrate-mysql": "^1.1.10"
},
"scripts": {
"dbup": "export DATABASE_URL=\"$(php dburl.php)?multipleStatements=true\"; db-migrate up"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment