mirror of
https://github.com/ngthanhvu/kr-phim.git
synced 2026-08-10 16:07:47 +00:00
feat: add movie management API and database schema
- Implemented movie CRUD operations with endpoints for creating, retrieving, updating, and deleting movies. - Added pagination and filtering capabilities for movie retrieval. - Integrated Redis caching for improved performance on movie data retrieval. - Created database schema for movies with necessary fields and types. - Added migration files for initial movie table creation and subsequent updates. - Configured database connection using Drizzle ORM with MySQL. - Established Redis connection utility for caching.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { mysqlTable, varchar, text, int, boolean, timestamp, json } from 'drizzle-orm/mysql-core'
|
||||
|
||||
export const movies = mysqlTable('movies', {
|
||||
id: int('id').primaryKey().autoincrement(),
|
||||
source: varchar('source', { length: 50 }).notNull(),
|
||||
slug: varchar('slug', { length: 500 }).notNull(),
|
||||
name: varchar('name', { length: 500 }).notNull(),
|
||||
originName: varchar('origin_name', { length: 500 }),
|
||||
thumb: text('thumb'),
|
||||
poster: text('poster'),
|
||||
year: int('year'),
|
||||
time: varchar('time', { length: 100 }),
|
||||
episode: varchar('episode', { length: 100 }),
|
||||
quality: varchar('quality', { length: 50 }),
|
||||
lang: varchar('lang', { length: 50 }),
|
||||
type: varchar('type', { length: 50 }),
|
||||
rating: int('rating'),
|
||||
content: text('content'),
|
||||
categories: json('categories').$type<string[]>(),
|
||||
countries: json('countries').$type<string[]>(),
|
||||
sources: json('sources').$type<{ source: string, slug: string, name?: string }[]>(),
|
||||
customPoster: text('custom_poster'),
|
||||
customThumb: text('custom_thumb'),
|
||||
customContent: text('custom_content'),
|
||||
customEpisodes: json('custom_episodes').$type<{ name: string, linkEmbed?: string, linkM3u8?: string }[]>(),
|
||||
active: boolean('active').notNull().default(false),
|
||||
syncedAt: timestamp('synced_at').notNull().defaultNow(),
|
||||
createdAt: timestamp('created_at').notNull().defaultNow(),
|
||||
updatedAt: timestamp('updated_at').notNull().defaultNow().onUpdateNow(),
|
||||
})
|
||||
|
||||
export type Movie = typeof movies.$inferSelect
|
||||
export type NewMovie = typeof movies.$inferInsert
|
||||
Reference in New Issue
Block a user