From 07d85b945783e8d75af0cc9f7666fbc8e35400a5 Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Tue, 17 Jan 2023 12:52:37 +1300 Subject: [PATCH] Deal with relay URLs ending in slash (nostr-types handled part of this) --- src/db/mod.rs | 1 + src/db/schema13.sql | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 src/db/schema13.sql 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) == '/';