#!/bin/bash

## Description: Pull pantheon database.
## Usage: db
## Example: "ddev db"

# Check if any tables exist in database.
# If not, pull database.

if [[ ! $(echo "SHOW TABLES;" | ddev mysql) || $1 == '-f' ]]; then
  ddev auth ssh
  ddev pull pantheon --skip-files -y
else
  echo 'A database is already installed. Use -f to force.'
fi
