21 lines
778 B
TypeScript
21 lines
778 B
TypeScript
import { sql } from "drizzle-orm";
|
|
import { integer, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core";
|
|
|
|
export const danmakuCache = sqliteTable(
|
|
"danmaku_cache",
|
|
{
|
|
id: text("id")
|
|
.primaryKey()
|
|
.$defaultFn(() => crypto.randomUUID()),
|
|
matchKey: text("match_key").notNull(),
|
|
payload: text("payload").notNull(),
|
|
source: text("source").notNull().default("open-network"),
|
|
expiresAt: integer("expires_at", { mode: "timestamp" }),
|
|
createdAt: integer("created_at", { mode: "timestamp" })
|
|
.notNull()
|
|
.default(sql`(unixepoch())`),
|
|
},
|
|
(t) => [uniqueIndex("danmaku_match_key_uq").on(t.matchKey)],
|
|
);
|
|
export type DanmakuCacheRow = typeof danmakuCache.$inferSelect;
|