Skip to content

Commit

Permalink
Use STRICT tables to enforce correct column value types
Browse files Browse the repository at this point in the history
  • Loading branch information
FluxCapacitor2 committed Sep 13, 2024
1 parent 952fc23 commit 8a185dd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/database/db_sqlite_setup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ CREATE TABLE IF NOT EXISTS crawl_queue(
depth INTEGER,
addedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
updatedAt DATETIME DEFAULT CURRENT_TIMESTAMP
);
) STRICT;

-- When a canonical URL is discovered, it is cached in this table to prevent excessively querying the target
CREATE TABLE IF NOT EXISTS canonicals(
source TEXT NOT NULL,
url TEXT NOT NULL,
canonical TEXT NOT NULL,
crawledAt DATETIME DEFAULT CURRENT_TIMESTAMP
);
) STRICT;

-- After a page is crawled, it is added to this table
CREATE TABLE IF NOT EXISTS pages(
Expand All @@ -30,7 +30,7 @@ CREATE TABLE IF NOT EXISTS pages(
title TEXT,
description TEXT,
content TEXT
);
) STRICT;

-- Ensure a page can only be queued and/or indexed once per source and that pages can only have one canonical per source
CREATE UNIQUE INDEX IF NOT EXISTS queue_source_url ON crawl_queue(source, url);
Expand Down

0 comments on commit 8a185dd

Please sign in to comment.