Deal with relay URLs ending in slash (nostr-types handled part of this)

This commit is contained in:
Mike Dilger 2023-01-17 12:52:37 +13:00
parent 76c9791d99
commit 07d85b9457
2 changed files with 8 additions and 0 deletions

View File

@ -118,6 +118,7 @@ fn upgrade(db: &Connection, mut version: u16) -> Result<(), Error> {
apply_sql!(db, version, 10, "schema10.sql"); apply_sql!(db, version, 10, "schema10.sql");
apply_sql!(db, version, 11, "schema11.sql"); apply_sql!(db, version, 11, "schema11.sql");
apply_sql!(db, version, 12, "schema12.sql"); apply_sql!(db, version, 12, "schema12.sql");
apply_sql!(db, version, 13, "schema13.sql");
tracing::info!("Database is at version {}", version); tracing::info!("Database is at version {}", version);
Ok(()) Ok(())
} }

7
src/db/schema13.sql Normal file
View File

@ -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) == '/';