Rocket/examples/todo/bootstrap.sh

18 lines
518 B
Bash
Raw Normal View History

#! /usr/bin/env bash
SCRIPT_PATH=$(cd "$(dirname "$0")" ; pwd -P)
DATABASE_URL="${SCRIPT_PATH}/db/db.sql"
pushd "${SCRIPT_PATH}" > /dev/null
# clear an existing database
rm -f "${DATABASE_URL}"
2016-09-30 22:39:55 +00:00
# install the diesel CLI tools if they're not installed
if ! command -v diesel >/dev/null 2>&1; then
2018-05-29 13:26:14 +00:00
cargo install diesel_cli --version '<= 1.2' --no-default-features --features=sqlite > /dev/null
2016-09-30 22:39:55 +00:00
fi
# create db/db.sql
diesel migration --database-url="${DATABASE_URL}" run > /dev/null
popd > /dev/null