Edit slug constraints on (kind, slug) for shows

This commit is contained in:
Zoe Roux
2026-02-19 13:48:27 +01:00
parent 31af752e2e
commit b7e1c4dc3e
7 changed files with 2206 additions and 5 deletions
+2 -2
View File
@@ -184,8 +184,8 @@ export const imagesH = new Elysia({ tags: ["images"] })
.where(
id !== "random"
? isUuid(id)
? eq(shows.id, id)
: eq(shows.slug, id)
? eq(staff.id, id)
: eq(staff.slug, id)
: undefined,
)
.orderBy(sql`random()`)
@@ -47,7 +47,7 @@ export const insertCollection = record(
...col,
})
.onConflictDoUpdate({
target: shows.slug,
target: [shows.kind, shows.slug],
set: {
...conflictUpdateAllExcept(shows, [
"pk",
+1 -1
View File
@@ -119,7 +119,7 @@ async function insertBaseShow(tx: Transaction, show: Show) {
.insert(shows)
.values(show)
.onConflictDoUpdate({
target: shows.slug,
target: [shows.kind, shows.slug],
set: conflictUpdateAllExcept(shows, ["pk", "id", "slug", "createdAt"]),
// if year is different, this is not an update but a conflict (ex: dune-1984 vs dune-2021)
setWhere: sql`date_part('year', ${shows.startAir}) = date_part('year', excluded."start_air")`,