Skip to content

Commit

Permalink
Add script to create database
Browse files Browse the repository at this point in the history
  • Loading branch information
omarlopesino committed Mar 19, 2024
1 parent 527b428 commit 3b3e47f
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 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 3b3e47f

Please sign in to comment.