Skip to content

Instantly share code, notes, and snippets.

@davidmfoley
Last active June 26, 2018 22:52
Show Gist options
  • Save davidmfoley/c40c199d096dfdb66b92e622adef5274 to your computer and use it in GitHub Desktop.
Save davidmfoley/c40c199d096dfdb66b92e622adef5274 to your computer and use it in GitHub Desktop.
DB_URLS = ( \
postgres://localhost/test_1 \
postgres://localhost/test_2 \
)
for db_url in "${DB_URLS[@]}"; do
echo "creating database `basename $db_url`"
createdb `basename $db_url` > /dev/null 2>&1
psql $db_url -c 'drop schema public cascade; create schema public;' -o /dev/null 2>/dev/null
psql $db_url -f "path/to/your/schema.sql" > /dev/null 2>/dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment