add db migration tool

This commit is contained in:
Laura Hausmann 2020-12-28 17:25:56 +01:00
parent 5971c8ff5d
commit 9d882d2c4a
Signed by: zotan
GPG Key ID: 5EC1D38FFC321311
3 changed files with 13 additions and 0 deletions

View File

@ -53,6 +53,7 @@
</e>
</e>
<e p="packages" t="ExcludeRecursive" />
<e p="v4_to_v5_migrator.sh" t="Include" />
<e p="wwwroot" t="Include">
<e p="css" t="Include">
<e p="fa.css" t="Include" />

BIN
database.init.sqlite Normal file

Binary file not shown.

12
v4_to_v5_migrator.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
# Requires jq and sqlite3
cp database.init.sqlite data/c3stream.sqlite
rm migration.sql
for row in $(cat "data/c3stream.user.json" | jq -c '.[]'); do
echo "INSERT INTO States (TalkId, UserId, State) VALUES ($(echo $row | jq '.TalkId'),$(echo $row | jq '.UserId'),$(echo $row | jq '.State'));" | tee -a migration.sql
done
cat migration.sql | sqlite3 data/c3stream.sqlite