-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquotes.ts
79 lines (70 loc) · 2.24 KB
/
quotes.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { relations } from "drizzle-orm";
import { index, int, text } from "drizzle-orm/sqlite-core";
import { sqliteTable } from "./_table";
export const episode = sqliteTable("episode", {
id: int("id").primaryKey({ autoIncrement: true }),
seasonId: int("season_id")
.notNull()
.references(() => season.id),
number: int("number"),
title: text("name"),
filePath: text("file_path").notNull(),
description: text("description"),
releaseDate: int("release_date", { mode: "timestamp" }),
});
export const episodeRelations = relations(episode, ({ many, one }) => ({
quote: many(quote),
season: one(season, {
fields: [episode.seasonId],
references: [season.id],
}),
}));
export const quote = sqliteTable("quote", {
id: int("id").primaryKey({ autoIncrement: true }),
index: int("index").notNull(),
episodeId: int("episode_id")
.notNull()
.references(() => episode.id),
text: text("text").notNull(),
startTime: int("start_time").notNull(),
endTime: int("end_time").notNull(),
character: text("character"),
featured: int("featured", { mode: "boolean" })
}, (table) => ({
textIdx: index("text_index").on(table.text)
}));
export const quoteRelations = relations(quote, ({ one }) => ({
episode: one(episode, {
fields: [quote.episodeId],
references: [episode.id],
}),
}));
export const season = sqliteTable("season", {
id: int("id").primaryKey({ autoIncrement: true }),
showId: int("show_id")
.notNull()
.references(() => show.id),
title: text("name").notNull(),
number: int("number"),
releaseDate: int("release_date", { mode: "timestamp" }),
streamingLink: text("streaming_link"),
streamingIconUrl: text("streaming_icon_url")
});
export const seasonRelations = relations(season, ({ many, one }) => ({
episode: many(episode),
show: one(show, {
fields: [season.showId],
references: [show.id],
}),
}));
export const show = sqliteTable("show", {
id: int("id").primaryKey({ autoIncrement: true }),
title: text("name").notNull(),
dirName: text("dir_name").notNull(),
description: text("description"),
iconUrl: text("icon_url").notNull(),
posterImageUrl: text("poster_image_url").notNull()
});
export const showRelations = relations(show, ({ many }) => ({
season: many(season),
}));