2016-08-07 02:57:44 +00:00
|
|
|
#! /usr/bin/env bash
|
|
|
|
|
2016-08-07 03:59:51 +00:00
|
|
|
SCRIPT_PATH=$(cd "$(dirname "$0")" ; pwd -P)
|
2017-07-29 04:34:59 +00:00
|
|
|
DATABASE_URL="${SCRIPT_PATH}/db/db.sql"
|
2016-08-07 02:57:44 +00:00
|
|
|
|
2017-07-29 04:34:59 +00:00
|
|
|
pushd "${SCRIPT_PATH}" > /dev/null
|
2017-06-02 04:59:06 +00:00
|
|
|
# clear an existing database
|
2017-07-29 04:34:59 +00:00
|
|
|
rm -f "${DATABASE_URL}"
|
2017-06-02 04:59:06 +00:00
|
|
|
|
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
|
2016-08-07 02:57:44 +00:00
|
|
|
|
|
|
|
# create db/db.sql
|
2017-07-29 04:34:59 +00:00
|
|
|
diesel migration --database-url="${DATABASE_URL}" run > /dev/null
|
2017-02-02 23:19:23 +00:00
|
|
|
popd > /dev/null
|