db: change anime category number type to number

This commit is contained in:
2026-02-09 18:51:30 -08:00
parent 7b8ccb0e83
commit 2bf5aeb1c0
5 changed files with 12 additions and 5 deletions

View File

@@ -7,6 +7,7 @@
"dev": "vite dev",
"build": "vite build",
"preview": "bun run build && wrangler dev",
"db:push": "drizzle-kit push",
"db:import": "bun run src/lib/db/import-amq.ts",
"format": "biome check --write",
"prepare": "svelte-kit sync || echo ''",

View File

@@ -14,7 +14,7 @@ import { getClientDb } from "$lib/db/client-db";
* This is intended for READ-ONLY browsing. Bump the version when you ship a new
* snapshot so clients refresh.
*/
export const AMQ_DB_SEED_VERSION = 3;
export const AMQ_DB_SEED_VERSION = 4;
const SEED_ASSET_PATH = "/data/amq.sqlite";
const seededStorageKey = (version: number) => `amq.sqlocal.seeded.v${version}`;

View File

@@ -375,7 +375,7 @@ export async function importAmqData(
malId: a.malId,
kitsuId: a.kitsuId,
categoryName: a.category.name,
categoryNumber: categoryNumberToText(a.category.number),
categoryNumber: a.category.number,
mainName: a.mainName,
mainNameEn: a.mainNames.EN,
mainNameJa: a.mainNames.JA,

View File

@@ -1,4 +1,10 @@
import { index, integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
import {
index,
integer,
real,
sqliteTable,
text,
} from "drizzle-orm/sqlite-core";
/**
* Core `anime` table.
@@ -21,7 +27,7 @@ export const anime = sqliteTable(
// Category object (name + number that can be number|string|null in source)
categoryName: text("category_name").notNull(),
categoryNumber: text("category_number"),
categoryNumber: real("category_number"),
// Names
mainName: text("main_name").notNull(),

View File

@@ -37,7 +37,7 @@ export const AmqAnimeSchema = z.object({
kitsuId: z.int().positive().nullable(),
category: z.object({
name: AmqAnimeCategory,
number: z.union([z.number(), z.string()]).nullable(),
number: z.coerce.number().nullable(),
}),
genres: z.array(AmqAnimeGenre),
tags: z.array(AmqAnimeTag),