From 0c9f66277ee982f97fdd264093f8a67e7b75444d Mon Sep 17 00:00:00 2001 From: Erin Nova Date: Tue, 25 Jul 2023 20:47:31 -0400 Subject: [PATCH] Rename table, add search_index --- crawler/src/main.rs | 2 +- migrations/20230725232149_cached_urls.sql | 5 ++--- migrations/20230726004317_index.sql | 12 ++++++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 migrations/20230726004317_index.sql diff --git a/crawler/src/main.rs b/crawler/src/main.rs index f88f2f1..1c84998 100644 --- a/crawler/src/main.rs +++ b/crawler/src/main.rs @@ -181,7 +181,7 @@ async fn insert_db(pool: &SqlitePool, page: &Page) { let id = sqlx::query!( r#" - REPLACE INTO cached_urls ( last_fetched, url, body ) + REPLACE INTO crawled_urls ( last_fetched, url, body ) VALUES ( ?1, ?2, ?3 ) "#, timestamp, diff --git a/migrations/20230725232149_cached_urls.sql b/migrations/20230725232149_cached_urls.sql index 53258bc..1d83204 100644 --- a/migrations/20230725232149_cached_urls.sql +++ b/migrations/20230725232149_cached_urls.sql @@ -1,7 +1,6 @@ --- Add migration script here -CREATE TABLE IF NOT EXISTS cached_urls +CREATE TABLE IF NOT EXISTS crawled_urls ( - last_fetched INTEGER NOT NULL, + last_fetched INTEGER PRIMARY KEY NOT NULL, url TEXT NOT NULL, body TEXT NOT NULL ); diff --git a/migrations/20230726004317_index.sql b/migrations/20230726004317_index.sql new file mode 100644 index 0000000..107178a --- /dev/null +++ b/migrations/20230726004317_index.sql @@ -0,0 +1,12 @@ +CREATE TABLE IF NOT EXISTS search_index +( + id INTEGER PRIMARY KEY NOT NULL, + url TEXT NOT NULL, + clicks INTEGER NOT NULL, + size INTEGER NOT NULL, + language TEXT NOT NULL, + title TEXT NOT NULL, + summary TEXT NOT NULL, + content TEXT NOT NULL, + last_updated INTEGER NOT NULL +);