#!/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
