Browse Source

add db migration tool

v5
Laura Hausmann 2 months ago
parent
commit
9d882d2c4a
Signed by: zotan GPG Key ID: 5EC1D38FFC321311
3 changed files with 13 additions and 0 deletions
  1. +1
    -0
      .idea/.idea.c3stream/.idea/contentModel.xml
  2. BIN
      database.init.sqlite
  3. +12
    -0
      v4_to_v5_migrator.sh

+ 1
- 0
.idea/.idea.c3stream/.idea/contentModel.xml 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 View File


+ 12
- 0
v4_to_v5_migrator.sh 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

Loading…
Cancel
Save