ssb: All initial population in transactions for correctness.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 30m29s
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 30m29s
This commit is contained in:
parent
8928e8722b
commit
240a8ce9c7
@ -121,6 +121,7 @@ void tf_ssb_db_init(tf_ssb_t* ssb)
|
||||
")");
|
||||
if (!_tf_ssb_db_has_rows(db, "PRAGMA table_list('messages_stats')"))
|
||||
{
|
||||
_tf_ssb_db_exec(db, "BEGIN TRANSACTION");
|
||||
_tf_ssb_db_exec(db,
|
||||
"CREATE TABLE IF NOT EXISTS messages_stats ("
|
||||
" author TEXT PRIMARY KEY,"
|
||||
@ -129,6 +130,7 @@ void tf_ssb_db_init(tf_ssb_t* ssb)
|
||||
")");
|
||||
_tf_ssb_db_exec(
|
||||
db, "INSERT OR REPLACE INTO messages_stats (author, max_sequence, max_timestamp) SELECT author, MAX(sequence), MAX(timestamp) FROM messages GROUP BY author");
|
||||
_tf_ssb_db_exec(db, "COMMIT TRANSACTION");
|
||||
}
|
||||
_tf_ssb_db_exec(db,
|
||||
"CREATE TRIGGER IF NOT EXISTS messages_ai_stats AFTER INSERT ON messages BEGIN INSERT INTO messages_stats(author, max_sequence, max_timestamp) VALUES (new.author, "
|
||||
@ -239,6 +241,7 @@ void tf_ssb_db_init(tf_ssb_t* ssb)
|
||||
|
||||
if (!_tf_ssb_db_has_rows(db, "PRAGMA table_list('messages_refs')"))
|
||||
{
|
||||
_tf_ssb_db_exec(db, "BEGIN TRANSACTION");
|
||||
_tf_ssb_db_exec(db,
|
||||
"CREATE TABLE IF NOT EXISTS messages_refs ("
|
||||
" message TEXT, "
|
||||
@ -253,6 +256,7 @@ void tf_ssb_db_init(tf_ssb_t* ssb)
|
||||
"j.value LIKE '%%%.sha256' OR "
|
||||
"j.value LIKE '@%.ed25519' "
|
||||
"ON CONFLICT DO NOTHING");
|
||||
_tf_ssb_db_exec(db, "COMMIT TRANSACTION");
|
||||
tf_printf("Done.\n");
|
||||
}
|
||||
|
||||
@ -273,6 +277,7 @@ void tf_ssb_db_init(tf_ssb_t* ssb)
|
||||
|
||||
if (!_tf_ssb_db_has_rows(db, "PRAGMA table_list('blobs_refs')"))
|
||||
{
|
||||
_tf_ssb_db_exec(db, "BEGIN TRANSACTION");
|
||||
_tf_ssb_db_exec(db,
|
||||
"CREATE TABLE IF NOT EXISTS blobs_refs ("
|
||||
" blob TEXT, "
|
||||
@ -285,6 +290,7 @@ void tf_ssb_db_init(tf_ssb_t* ssb)
|
||||
"SELECT blobs.id, j.value FROM blobs, json_tree(blobs.content) as j WHERE "
|
||||
"json_valid(blobs.content) AND j.value LIKE '&%.sha256' "
|
||||
"ON CONFLICT DO NOTHING");
|
||||
_tf_ssb_db_exec(db, "COMMIT TRANSACTION");
|
||||
tf_printf("Done.\n");
|
||||
}
|
||||
_tf_ssb_db_exec(db, "DROP TRIGGER IF EXISTS blobs_ai_refs");
|
||||
|
Loading…
x
Reference in New Issue
Block a user