mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-05-22 15:12:28 -04:00
Create migration & fix update statment
This commit is contained in:
@@ -27,6 +27,7 @@ export const insertCollection = async (
|
||||
startAir: show.kind === "movie" ? show.airDate : show.startAir,
|
||||
endAir: show.kind === "movie" ? show.airDate : show.endAir,
|
||||
nextRefresh: show.nextRefresh,
|
||||
entriesCount: 0,
|
||||
...col,
|
||||
})
|
||||
.onConflictDoUpdate({
|
||||
|
||||
@@ -101,8 +101,8 @@ export async function updateAvailableCount(
|
||||
return await db
|
||||
.update(shows)
|
||||
.set({
|
||||
availableCount: db
|
||||
.select({ availableCount: count() })
|
||||
availableCount: sql`${db
|
||||
.select({ count: count() })
|
||||
.from(entries)
|
||||
.where(
|
||||
and(
|
||||
@@ -114,12 +114,12 @@ export async function updateAvailableCount(
|
||||
.where(eq(entryVideoJoin.entryPk, entries.pk)),
|
||||
),
|
||||
),
|
||||
),
|
||||
)}`,
|
||||
...(updateEntryCount && {
|
||||
entriesCount: db
|
||||
.select({ entriesCount: count() })
|
||||
entriesCount: sql`${db
|
||||
.select({ count: count() })
|
||||
.from(entries)
|
||||
.where(eq(entries.showPk, shows.pk)),
|
||||
.where(eq(entries.showPk, shows.pk))}`,
|
||||
}),
|
||||
})
|
||||
.where(eq(shows.pk, sql`any(${sqlarr(showPks)})`));
|
||||
|
||||
Reference in New Issue
Block a user