mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-25 10:09:08 -05:00
improvement: clear out hidden events during schema upgrade
This commit is contained in:
parent
7021f102e8
commit
f543957b34
|
@ -314,8 +314,9 @@ pub async fn db_writer(
|
||||||
notice_tx.try_send(Notice::duplicate(event.id)).ok();
|
notice_tx.try_send(Notice::duplicate(event.id)).ok();
|
||||||
} else {
|
} else {
|
||||||
info!(
|
info!(
|
||||||
"persisted event: {:?} from: {:?} in: {:?}",
|
"persisted event: {:?} (kind={}) from: {:?} in: {:?}",
|
||||||
event.get_event_id_prefix(),
|
event.get_event_id_prefix(),
|
||||||
|
event.kind,
|
||||||
event.get_author_prefix(),
|
event.get_author_prefix(),
|
||||||
start.elapsed()
|
start.elapsed()
|
||||||
);
|
);
|
||||||
|
|
|
@ -626,7 +626,6 @@ fn mig_14_to_15(conn: &mut PooledConnection) -> Result<usize> {
|
||||||
let upgrade_sql = r##"
|
let upgrade_sql = r##"
|
||||||
CREATE INDEX IF NOT EXISTS author_created_at_index ON event(author,created_at);
|
CREATE INDEX IF NOT EXISTS author_created_at_index ON event(author,created_at);
|
||||||
CREATE INDEX IF NOT EXISTS author_kind_index ON event(author,kind);
|
CREATE INDEX IF NOT EXISTS author_kind_index ON event(author,kind);
|
||||||
pragma optimize;
|
|
||||||
PRAGMA user_version = 15;
|
PRAGMA user_version = 15;
|
||||||
"##;
|
"##;
|
||||||
match conn.execute_batch(upgrade_sql) {
|
match conn.execute_batch(upgrade_sql) {
|
||||||
|
@ -638,5 +637,17 @@ PRAGMA user_version = 15;
|
||||||
panic!("database could not be upgraded");
|
panic!("database could not be upgraded");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// clear out hidden events
|
||||||
|
let clear_hidden_sql = r##"DELETE FROM event WHERE HIDDEN=true;"##;
|
||||||
|
info!("removing hidden events; this may take awhile...");
|
||||||
|
match conn.execute_batch(clear_hidden_sql) {
|
||||||
|
Ok(()) => {
|
||||||
|
info!("all hidden events removed");
|
||||||
|
},
|
||||||
|
Err(err) => {
|
||||||
|
error!("delete failed: {}", err);
|
||||||
|
panic!("could not remove hidden events");
|
||||||
|
}
|
||||||
|
}
|
||||||
Ok(15)
|
Ok(15)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user