#!/bin/sh
set -e

SCRIPTPATH=$(dirname "$0")

export DATABASE_URL="/tmp/test_examples.db"

if [ -z "$BACKEND" ]; then
    export BACKEND="sqlite"
fi

cd "$SCRIPTPATH"

if [ -z "${BACKEND##*sqlite*}" ]; then
    find . -maxdepth 1 -mindepth 1 -type d | while read -r dir; do
        cd "$dir"
        ../../../bin/diesel database reset
        cargo build
        cd ..
    done
fi
