52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import {
|
|
index,
|
|
integer,
|
|
real,
|
|
sqliteTable,
|
|
text,
|
|
} from "drizzle-orm/sqlite-core";
|
|
|
|
/**
|
|
* Core `anime` table.
|
|
*
|
|
* Normalized schema for AMQ source data (imported from JSON).
|
|
* Keeps original AMQ integer identifiers where present (annId, etc.).
|
|
*
|
|
* Source: AmqAnimeSchema
|
|
*/
|
|
export const anime = sqliteTable(
|
|
"anime",
|
|
{
|
|
/** AMQ anime ID */
|
|
annId: integer("ann_id").notNull().primaryKey(),
|
|
|
|
// External IDs from the source
|
|
aniListId: integer("anilist_id"),
|
|
malId: integer("mal_id").notNull(),
|
|
kitsuId: integer("kitsu_id"),
|
|
|
|
// Category object (name + number that can be number|string|null in source)
|
|
categoryName: text("category_name").notNull(),
|
|
categoryNumber: real("category_number"),
|
|
|
|
// Names
|
|
mainName: text("main_name").notNull(),
|
|
mainNameEn: text("main_name_en"),
|
|
mainNameJa: text("main_name_ja"),
|
|
|
|
// Season/year
|
|
year: integer("year").notNull(),
|
|
seasonId: integer("season_id").notNull(), // 0..3 from Season enum
|
|
|
|
// Counts
|
|
opCount: integer("op_count").notNull(),
|
|
edCount: integer("ed_count").notNull(),
|
|
insertCount: integer("insert_count").notNull(),
|
|
},
|
|
(t) => ({
|
|
aniListIndex: index("anime_anilist_id_uq").on(t.aniListId),
|
|
malIndex: index("anime_mal_id_uq").on(t.malId),
|
|
kitsuIndex: index("anime_kitsu_id_uq").on(t.kitsuId),
|
|
}),
|
|
);
|