diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-08-31 23:44:08 +0200 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-08-31 23:44:08 +0200 |
| commit | 84d9a86be8ee216b47920ff3f98b567aa1d296c0 (patch) | |
| tree | ec7fdb3a3ab0725b843225894e0535d3391d09a6 /scripts/mkdb.sh | |
| download | server-84d9a86be8ee216b47920ff3f98b567aa1d296c0.zip | |
chore: Initial commit
Diffstat (limited to 'scripts/mkdb.sh')
| -rwxr-xr-x | scripts/mkdb.sh | 30 |
1 files changed, 30 insertions, 0 deletions
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 <benedikt.peetz@b-peetz.de> +# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de> +# 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 <https://www.gnu.org/licenses/gpl-3.0.txt>. + +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 |
