xenu_nntp/db/newsgroup.sql
2024-11-25 17:16:34 -05:00

31 lines
822 B
SQL

begin transaction;
create table newsgroup (
id INTEGER PRIMARY KEY NOT NULL,
created_on DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
name TEXT NOT NULL,
description TEXT NOT NULL
);
create table newsgroup_message (
id INTEGER PRIMARY KEY NOT NULL,
created_on DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
newsgroup_id INTEGER NOT NULL,
message_id TEXT NOT NULL UNIQUE,
parent_id TEXT,
sender TEXT NOT NULL,
subject TEXT NOT NULL,
content TEXT NOT NULL,
FOREIGN KEY(newsgroup_id) REFERENCES newsgroup(id)
);
create index newsgroup_message_newsgroup_id_idx on newsgroup_message (
newsgroup_id, id
);
create index newsgroup_message_newsgroup_date_idx on newsgroup_message (
newsgroup_id, created_on
);
commit;