-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve connect-to-mysql, add creation of magento database if it does…
… not exist
- Loading branch information
Showing
2 changed files
with
79 additions
and
17 deletions.
There are no files selected for viewing
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
18 changes: 18 additions & 0 deletions
18
build-packages/magento-scripts/lib/tasks/mysql/create-magento-database.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const { execAsyncSpawn } = require('../../util/exec-async-command'); | ||
|
||
/** | ||
* Will create database 'magento' in MySQL if it does not exist for some reason | ||
* @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>} | ||
*/ | ||
const createMagentoDatabase = () => ({ | ||
title: 'Creating Magento database in MySQL', | ||
task: async (ctx) => { | ||
const { mysql } = ctx.config.docker.getContainers(); | ||
|
||
await execAsyncSpawn(`docker exec ${mysql.name} mysql -umagento -pmagento -h 127.0.0.1 -e "CREATE DATABASE IF NOT EXISTS magento;"`); | ||
} | ||
}); | ||
|
||
module.exports = { | ||
createMagentoDatabase | ||
}; |