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)
|
2016-08-07 06:14:05 +00:00
|
|
|
DATABASE_URL=${SCRIPT_PATH}/db/db.sql
|
2016-08-07 02:57:44 +00:00
|
|
|
|
2016-09-30 22:39:55 +00:00
|
|
|
pushd $SCRIPT_PATH > /dev/null
|
2017-06-02 04:59:06 +00:00
|
|
|
# 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
|
2017-03-08 23:08:13 +00:00
|
|
|
cargo install diesel_cli --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-02-02 09:08:43 +00:00
|
|
|
diesel migration --database-url=$DATABASE_URL run > /dev/null
|
2017-02-02 23:19:23 +00:00
|
|
|
popd > /dev/null
|
2017-02-02 08:41:47 +00:00
|
|
|
|
|
|
|
echo "export DATABASE_URL=$DATABASE_URL"
|