update amq schema to add some extra fields
This commit is contained in:
@@ -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 = 1;
|
||||
export const AMQ_DB_SEED_VERSION = 2;
|
||||
|
||||
const SEED_ASSET_PATH = "/data/amq.sqlite";
|
||||
const seededStorageKey = (version: number) => `amq.sqlocal.seeded.v${version}`;
|
||||
|
||||
@@ -332,6 +332,9 @@ export async function importAmqData(
|
||||
name: s.name,
|
||||
category: s.category,
|
||||
fileName: s.fileName,
|
||||
fileName480: s.fileNameMap["480"],
|
||||
fileName720: s.fileNameMap["720"],
|
||||
meanVolume: s.meanVolume,
|
||||
songArtistId: s.songArtistId,
|
||||
songGroupId: s.songGroupId,
|
||||
composerArtistId: s.composerArtistId,
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
index,
|
||||
integer,
|
||||
primaryKey,
|
||||
real,
|
||||
sqliteTable,
|
||||
text,
|
||||
uniqueIndex,
|
||||
@@ -87,6 +88,9 @@ export const songsTable = sqliteTable(
|
||||
* https://nawdist.animemusicquiz.com/{fileName}
|
||||
*/
|
||||
fileName: text("file_name"),
|
||||
fileName480: text("file_name_480"),
|
||||
fileName720: text("file_name_720"),
|
||||
meanVolume: real("mean_volume"),
|
||||
|
||||
/**
|
||||
* Primary artist/group ids for this song (nullable in source).
|
||||
@@ -123,7 +127,6 @@ export const songsTable = sqliteTable(
|
||||
},
|
||||
(t) => ({
|
||||
songIdIndex: index("songs_song_id_idx").on(t.songId),
|
||||
fileNameIndex: index("songs_file_name_idx").on(t.fileName),
|
||||
songArtistIdIndex: index("songs_song_artist_id_idx").on(t.songArtistId),
|
||||
songGroupIdIndex: index("songs_song_group_id_idx").on(t.songGroupId),
|
||||
}),
|
||||
@@ -161,7 +164,9 @@ export const artistGroupsTable = sqliteTable(
|
||||
{
|
||||
songArtistId: integer("song_artist_id")
|
||||
.notNull()
|
||||
.references(() => artistsTable.songArtistId, { onDelete: "cascade" }),
|
||||
.references(() => artistsTable.songArtistId, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
songGroupId: integer("song_group_id")
|
||||
.notNull()
|
||||
.references(() => groupsTable.songGroupId, { onDelete: "cascade" }),
|
||||
@@ -187,7 +192,9 @@ export const groupArtistMembersTable = sqliteTable(
|
||||
.references(() => groupsTable.songGroupId, { onDelete: "cascade" }),
|
||||
songArtistId: integer("song_artist_id")
|
||||
.notNull()
|
||||
.references(() => artistsTable.songArtistId, { onDelete: "cascade" }),
|
||||
.references(() => artistsTable.songArtistId, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
},
|
||||
(t) => ({
|
||||
pk: primaryKey({
|
||||
@@ -239,7 +246,9 @@ export const artistAltNamesTable = sqliteTable(
|
||||
*/
|
||||
songArtistId: integer("song_artist_id")
|
||||
.notNull()
|
||||
.references(() => artistsTable.songArtistId, { onDelete: "cascade" }),
|
||||
.references(() => artistsTable.songArtistId, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
|
||||
/**
|
||||
* The alternate-name entry is keyed by an artist id in the source:
|
||||
@@ -249,7 +258,9 @@ export const artistAltNamesTable = sqliteTable(
|
||||
*/
|
||||
altSongArtistId: integer("alt_song_artist_id")
|
||||
.notNull()
|
||||
.references(() => artistsTable.songArtistId, { onDelete: "cascade" }),
|
||||
.references(() => artistsTable.songArtistId, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
|
||||
name: text("name").notNull(),
|
||||
},
|
||||
@@ -410,7 +421,10 @@ export const animeSongLinksTable = sqliteTable(
|
||||
dub: integer("dub").notNull(),
|
||||
},
|
||||
(t) => ({
|
||||
pk: primaryKey({ name: "anime_songs_pk", columns: [t.annId, t.annSongId] }),
|
||||
pk: primaryKey({
|
||||
name: "anime_songs_pk",
|
||||
columns: [t.annId, t.annSongId],
|
||||
}),
|
||||
annIdIndex: index("anime_songs_ann_id_idx").on(t.annId),
|
||||
songIdIndex: index("anime_songs_song_id_idx").on(t.annSongId),
|
||||
}),
|
||||
|
||||
@@ -22,8 +22,9 @@ export const AmqSongSchema = z.object({
|
||||
globalPercent: z.number().int().min(0).max(100),
|
||||
fileName: z.string().nullable(),
|
||||
fileNameMap: z.object({
|
||||
0: z.string().optional(),
|
||||
480: z.string().optional(),
|
||||
720: z.string().optional(),
|
||||
"0": z.string().optional(),
|
||||
"480": z.string().optional(),
|
||||
"720": z.string().optional(),
|
||||
}),
|
||||
meanVolume: z.number().negative().nullable(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user