Open History to see the last commit
1import {
2 pgTable,
3 integer,
4 text,
5 boolean,
6 primaryKey,
7 index,
8 bigint,
9} from "drizzle-orm/pg-core";
10export const events = pgTable("hn_events", {
11 id: bigint("id", { mode: "number" }).primaryKey(),
12 itemId: integer("item_id").notNull(),
13 storyId: integer("story_id").notNull(),
14 kind: text("kind").notNull(),
15 label: text("label").notNull(),
16 details: text("details").notNull(),
17 occurredAt: bigint("occurred_at", { mode: "number" }).notNull(),
18});
19export const items = pgTable("hn_items", {
20 id: integer("id").primaryKey(),
21 type: text("type").notNull(),
22 title: text("title").notNull(),
23 url: text("url"),
24 author: text("author"),
25 created: integer("created").notNull(),
26 score: integer("score").notNull(),
27 comments: integer("comments").notNull(),
28 deleted: boolean("deleted").notNull(),
29 dead: boolean("dead").notNull(),
30 committedAt: text("committed_at").notNull(),
31 body: text("body"),
32});
33export const entries = pgTable(
34 "hn_feed_entries",
35 {
36 feed: text("feed").notNull(),
37 itemId: integer("item_id")
38 .notNull()
39 .references(() => items.id),
40 rank: integer("rank").notNull(),
41 },
42 (t) => [
43 primaryKey({ columns: [t.feed, t.itemId] }),
44 index("hn_feed_rank").on(t.feed, t.rank, t.itemId),
45 ],
46);
47export const comments = pgTable(
48 "hn_comments",
49 {
50 storyId: integer("story_id").notNull(),
51 itemId: integer("item_id").notNull(),
52 parentId: integer("parent_id").notNull(),
53 path: text("path").notNull(),
54 depth: integer("depth").notNull(),
55 author: text("author"),
56 created: integer("created").notNull(),
57 text: text("text").notNull(),
58 deleted: boolean("deleted").notNull(),
59 dead: boolean("dead").notNull(),
60 committedAt: text("committed_at").notNull(),
61 },
62 (t) => [primaryKey({ columns: [t.storyId, t.itemId] })],
63);