feat(database): add first version of the feeds table

This commit is contained in:
David Bailey 2025-04-10 10:34:33 +02:00
parent bbc093b497
commit 143c932c88

View file

@ -55,6 +55,34 @@ CREATE TABLE dev_post_markdown (
FULLTEXT(post_markdown)
);
CREATE TABLE dev_feeds (
post_id INTEGER NOT NULL,
feed_key VARCHAR(32),
feed_id VARCHAR(40) NOT NULL,
feed_created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
feed_metadata JSON DEFAULT NULL,
feed_text TEXT,
-- Primary key as true ID to allow for deterministic saving/recreating
CONSTRAINT PK_FEED PRIMARY KEY(post_id, feed_key, feed_id),
FOREIGN KEY(post_id) REFERENCES dev_posts(post_id)
ON DELETE CASCADE,
-- Make it possible to look up changes from e.g. a commit hash inexpensively
INDEX(feed_id),
-- Make it possible to look up specific post feeds efficiently (e.g. changelog)
INDEX(post_id, feed_key, feed_created_at),
-- Make it possible to globally look up specific feeds efficiently
INDEX(feed_key, feed_created_at),
-- And just in general, make searching feeds in a timeframe efficient
INDEX(feed_created_at),
FULLTEXT(feed_text)
);
CREATE TABLE analytics_summations (
time_bucket DATETIME NOT NULL,
metric VARCHAR(16) NOT NULL,