memorium/lib/sqlite/schema.ts

56 lines
1.5 KiB
TypeScript
Raw Normal View History

import { int, integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
import { sql } from "drizzle-orm/sql";
2025-01-05 21:58:07 +01:00
import { contentType } from "https://deno.land/std@0.216.0/media_types/content_type.ts";
export const userTable = sqliteTable("user", {
id: text()
.primaryKey(),
createdAt: integer("created_at", { mode: "timestamp" })
.default(sql`(current_timestamp)`)
.notNull(),
email: text()
.notNull(),
name: text()
.notNull(),
});
export const sessionTable = sqliteTable("session", {
id: text("id")
.primaryKey(),
createdAt: integer("created_at", { mode: "timestamp_ms" }).default(
sql`(current_timestamp)`,
),
expiresAt: integer("expires_at", { mode: "timestamp" })
.notNull(),
userId: text("user_id")
.notNull(),
});
export const performanceTable = sqliteTable("performance", {
path: text().notNull(),
search: text(),
time: int().notNull(),
createdAt: integer("created_at", {
mode: "timestamp_ms",
}).default(sql`(STRFTIME('%s', 'now') * 1000)`),
});
export const imageTable = sqliteTable("image", {
createdAt: integer("created_at", { mode: "timestamp" }).default(
sql`(current_timestamp)`,
),
url: text().notNull(),
average: text().notNull(),
blurhash: text().notNull(),
mime: text().notNull(),
});
2025-01-05 21:58:07 +01:00
export const documentTable = sqliteTable("document", {
name: text().notNull().primaryKey(),
lastModified: integer("last_modified").notNull(),
content: text(),
contentType: text("content_type").notNull(),
size: integer().notNull(),
perm: text().notNull(),
});