diff --git a/src/db/mod.rs b/src/db/mod.rs index 1598a594..d5f59145 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -118,6 +118,7 @@ fn upgrade(db: &Connection, mut version: u16) -> Result<(), Error> { apply_sql!(db, version, 10, "schema10.sql"); apply_sql!(db, version, 11, "schema11.sql"); apply_sql!(db, version, 12, "schema12.sql"); + apply_sql!(db, version, 13, "schema13.sql"); tracing::info!("Database is at version {}", version); Ok(()) } diff --git a/src/db/schema13.sql b/src/db/schema13.sql new file mode 100644 index 00000000..e411b5eb --- /dev/null +++ b/src/db/schema13.sql @@ -0,0 +1,7 @@ + +-- 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) == '/';