diff options
Diffstat (limited to 'scripts/mkdb.sh')
-rwxr-xr-x | scripts/mkdb.sh | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/scripts/mkdb.sh b/scripts/mkdb.sh index 9ce5dd8..6674841 100755 --- a/scripts/mkdb.sh +++ b/scripts/mkdb.sh @@ -11,11 +11,19 @@ # If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. root="$(dirname "$0")/.." -db="$root/target/database.sqlite" +db="${DATABASE_URL#sqlite://}" [ -f "$db" ] && rm "$db" [ -d "$root/target" ] || mkdir "$root/target" -sqlite3 "$db" <"$root/yt/src/storage/video_database/schema.sql" +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 |