Skip to content

Commit

Permalink
Merge pull request #135 from Metadrop/feature/create-database-script
Browse files Browse the repository at this point in the history
Add script to create database
  • Loading branch information
rsanzante authored Mar 19, 2024
2 parents 527b428 + bff202f commit 002e683
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions scripts/create-database.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

# Creates secondary database. Usage: ./scripts/create-database legacy
set -e

DB_NAME=$1
PROJECT_ROOT="./"
MYSQL_ROOT_PASS=`egrep DB_ROOT_PASSWORD ${PROJECT_ROOT}/.env | sed s/DB_ROOT_PASSWORD=//`
MYSQL_HOST=`egrep DB_HOST ${PROJECT_ROOT}/.env | sed s/DB_HOST=//`

docker compose exec -T mariadb mysql -u root -p${MYSQL_ROOT_PASS} -h ${MYSQL_HOST} -e "CREATE DATABASE IF NOT EXISTS ${DB_NAME};GRANT ALL PRIVILEGES ON ${DB_NAME}.* TO 'drupal'@'%';"

0 comments on commit 002e683

Please sign in to comment.