28 lines
718 B
TypeScript
28 lines
718 B
TypeScript
|
|
import {
|
||
|
|
pgTable,
|
||
|
|
text,
|
||
|
|
timestamp,
|
||
|
|
bigint,
|
||
|
|
integer,
|
||
|
|
index,
|
||
|
|
} from "drizzle-orm/pg-core";
|
||
|
|
|
||
|
|
export const files = pgTable(
|
||
|
|
"files",
|
||
|
|
{
|
||
|
|
id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
||
|
|
title: text("title"),
|
||
|
|
description: text("description"),
|
||
|
|
filename: text("filename").notNull(),
|
||
|
|
mime_type: text("mime_type"),
|
||
|
|
filesize: bigint("filesize", { mode: "number" }),
|
||
|
|
duration: integer("duration"),
|
||
|
|
uploaded_by: text("uploaded_by"),
|
||
|
|
date_created: timestamp("date_created").notNull().defaultNow(),
|
||
|
|
},
|
||
|
|
(t) => [index("files_uploaded_by_idx").on(t.uploaded_by)],
|
||
|
|
);
|
||
|
|
|
||
|
|
export type File = typeof files.$inferSelect;
|
||
|
|
export type NewFile = typeof files.$inferInsert;
|