SCHEMA 17 - crude deletion of relays ending in slash (it's not critical data)

This commit is contained in:
Mike Dilger 2023-01-30 15:04:05 +13:00
parent 9527fa78d6
commit f38cc472c8
2 changed files with 13 additions and 1 deletions

View File

@ -103,7 +103,7 @@ macro_rules! apply_sql {
}
fn upgrade(db: &Connection, mut version: u16) -> Result<(), Error> {
let current_version = 16;
let current_version = 17;
if version > current_version {
panic!(
"Database version {} is newer than this binary which expects version {}.",
@ -129,6 +129,7 @@ fn upgrade(db: &Connection, mut version: u16) -> Result<(), Error> {
apply_sql!(db, version, 14, "schema14.sql");
apply_sql!(db, version, 15, "schema15.sql");
apply_sql!(db, version, 16, "schema16.sql");
apply_sql!(db, version, 17, "schema17.sql");
tracing::info!("Database is at version {}", version);
Ok(())
}

11
src/db/schema17.sql Normal file
View File

@ -0,0 +1,11 @@
-- I tried to merge records with relays ending in '/' to records where they didn't, but SQLITE makes it very hard to update joins (you can't do it directly, and I think the join ON clause is too complex to use EXISTS tricks).
-- So I'm just going to delete such records. The data lost is statistical and not critical.
DELETE FROM event_seen WHERE SUBSTR(relay, LENGTH(relay), 1) == '/';
DELETE FROM person_relay WHERE SUBSTR(relay, LENGTH(relay), 1) == '/';
DELETE FROM relay WHERE SUBSTR(url, LENGTH(url), 1) == '/';
DELETE FROM event_seen WHERE SUBSTR(relay, 0, 15) == 'wss://127.0.0.1';
DELETE FROM person_relay WHERE SUBSTR(relay, 0, 15) == 'wss://127.0.0.1';
DELETE FROM relay WHERE SUBSTR(url, 0, 15) == 'wss://127.0.0.1';