From 84d9a86be8ee216b47920ff3f98b567aa1d296c0 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sun, 31 Aug 2025 23:44:08 +0200 Subject: chore: Initial commit --- scripts/mkdb.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 scripts/mkdb.sh (limited to 'scripts/mkdb.sh') diff --git a/scripts/mkdb.sh b/scripts/mkdb.sh new file mode 100755 index 0000000..c9895f8 --- /dev/null +++ b/scripts/mkdb.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env sh + +# rocie - An enterprise grocery management system +# +# Copyright (C) 2024 Benedikt Peetz +# Copyright (C) 2025 Benedikt Peetz +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This file is part of Rocie. +# +# You should have received a copy of the License along with this program. +# If not, see . + +root="$(dirname "$0")/.." +db="${DATABASE_URL#sqlite://}" + +[ -f "$db" ] && rm "$db" +[ -d "$root/target" ] || mkdir "$root/target" + +fd . "$root/crates/yt/src/storage/migrate/sql" | while read -r sql_file; do + echo "Applying sql migration file: $(basename "$sql_file").." + { + # NOTE(@bpeetz): The wrapping in a transaction is needed to simulate the rust code. <2025-05-07> + echo "BEGIN TRANSACTION;" + cat "$sql_file" + echo "COMMIT TRANSACTION;" + } | sqlite3 "$db" +done + +# vim: ft=sh -- cgit 1.4.1