25 lines
861 B
TypeScript
25 lines
861 B
TypeScript
import { sql } from "drizzle-orm";
|
|
import { pgTable, text, varchar, integer, timestamp } from "drizzle-orm/pg-core";
|
|
import { createInsertSchema } from "drizzle-zod";
|
|
import { z } from "zod";
|
|
|
|
export const videos = pgTable("videos", {
|
|
id: varchar("id").primaryKey(),
|
|
title: text("title").notNull(),
|
|
description: text("description"),
|
|
thumbnailUrl: text("thumbnail_url").notNull(),
|
|
videoUrl: text("video_url").notNull(),
|
|
duration: integer("duration").notNull(), // in seconds
|
|
views: integer("views").notNull().default(0),
|
|
category: text("category"),
|
|
createdAt: timestamp("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
});
|
|
|
|
export const insertVideoSchema = createInsertSchema(videos).omit({
|
|
id: true,
|
|
createdAt: true,
|
|
});
|
|
|
|
export type InsertVideo = z.infer<typeof insertVideoSchema>;
|
|
export type Video = typeof videos.$inferSelect;
|