#!/bin/bash
#
# This runs the DBIx schema loader, for easy rerunning since it's a
# lengthy command.

set -o errexit
set -o nounset
set -o pipefail
shopt -s globstar nullglob

declare -r rundir="$(realpath $(dirname $0)/..)"
if [[ "$PWD" != "$rundir" ]]; then
    echo "Run me in your checkout's root, i.e. '$rundir'" >&2
    exit 1
else
    dbicdump \
        -o dump_directory=./lib \
        -o components='["InflateColumn::DateTime"]' \
        -o debug=0 \
        "Book::Schema" "dbi:Pg:dbname=pg_book_catalog" pgc_owner
fi

exit 0
