diff options
author | Joris | 2021-01-03 13:40:40 +0100 |
---|---|---|
committer | Joris | 2021-01-03 13:54:20 +0100 |
commit | 11052951b74b9ad4b6a9412ae490086235f9154b (patch) | |
tree | 64526ac926c1bf470ea113f6cac8a33158684e8d /bin/db | |
parent | 371449b0e312a03162b78797b83dee9d81706669 (diff) |
Rewrite in Rust
Diffstat (limited to 'bin/db')
-rwxr-xr-x | bin/db | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -euo pipefail +cd $(dirname "$0")/.. + +DB_PATH="database.db" + +if [ "$1" == "init" ]; then + + if [ -f "$DB_PATH" ]; then + rm "$DB_PATH" + fi + + for MIGRATION in $(ls sql/migrations); do + printf "\n- Applying sql/migrations/$MIGRATION\n\n" + sqlite3 database.db < "sql/migrations/$MIGRATION" + done + + printf "\n- Applying sql/fixtures.sql\n\n" + sqlite3 database.db < sql/fixtures.sql + +else + + echo "Usage: $0 init" + exit 1 + +fi |