about summary refs log tree commit diff stats
path: root/scripts/mkdb.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/mkdb.sh')
-rwxr-xr-xscripts/mkdb.sh11
1 files changed, 8 insertions, 3 deletions
diff --git a/scripts/mkdb.sh b/scripts/mkdb.sh
index 6bcebaf..6674841 100755
--- a/scripts/mkdb.sh
+++ b/scripts/mkdb.sh
@@ -11,14 +11,19 @@
 # If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
 
 root="$(dirname "$0")/.."
-db="$root/target/database.sqlx"
+db="${DATABASE_URL#sqlite://}"
 
 [ -f "$db" ] && rm "$db"
 [ -d "$root/target" ] || mkdir "$root/target"
 
-fd . "$root/yt/src/storage/migrate/sql" | while read -r sql_file; do
+fd . "$root/crates/yt/src/storage/migrate/sql" | while read -r sql_file; do
     echo "Applying sql migration file: $(basename "$sql_file").."
-    sqlite3 "$db" <"$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