fix: update database schema for Immich v1.99+ compatibility
- Rename album_asset columns: albumsId -> albumId, assetsId -> assetId - Remove sidecarPath field (no longer exists in Immich v2.x schema) - Update all API files referencing these columns Fixes #214, #212 Tested with Immich v2.4.1
This commit is contained in:
1 parent
5af9e85f16
commit
4334d03464
20 files changed
+42
-43
No files matched your search
@@ -36,7 +36,7 @@ export default async function handler(
|
|||||||
duration: assets.duration,
|
duration: assets.duration,
|
||||||
encodedVideoPath: assets.encodedVideoPath,
|
encodedVideoPath: assets.encodedVideoPath,
|
||||||
originalFileName: assets.originalFileName,
|
originalFileName: assets.originalFileName,
|
||||||
sidecarPath: assets.sidecarPath,
|
|
||||||
deletedAt: assets.deletedAt,
|
deletedAt: assets.deletedAt,
|
||||||
localDateTime: assets.localDateTime,
|
localDateTime: assets.localDateTime,
|
||||||
exifImageWidth: exif.exifImageWidth,
|
exifImageWidth: exif.exifImageWidth,
|
||||||
@@ -46,12 +46,12 @@ export default async function handler(
|
|||||||
orientation: exif.orientation,
|
orientation: exif.orientation,
|
||||||
})
|
})
|
||||||
.from(albumsAssetsAssets)
|
.from(albumsAssetsAssets)
|
||||||
.leftJoin(assets, eq(albumsAssetsAssets.assetsId, assets.id))
|
.leftJoin(assets, eq(albumsAssetsAssets.assetId, assets.id))
|
||||||
.leftJoin(exif, eq(assets.id, exif.assetId))
|
.leftJoin(exif, eq(assets.id, exif.assetId))
|
||||||
.leftJoin(assetFaces, eq(assets.id, assetFaces.assetId))
|
.leftJoin(assetFaces, eq(assets.id, assetFaces.assetId))
|
||||||
.leftJoin(person, eq(assetFaces.personId, person.id))
|
.leftJoin(person, eq(assetFaces.personId, person.id))
|
||||||
.where(and(
|
.where(and(
|
||||||
eq(albumsAssetsAssets.albumsId, id),
|
eq(albumsAssetsAssets.albumId, id),
|
||||||
eq(assets.visibility, "timeline"),
|
eq(assets.visibility, "timeline"),
|
||||||
eq(assets.status, "active"),
|
eq(assets.status, "active"),
|
||||||
faceId ? eq(assetFaces.personId, faceId) : undefined,
|
faceId ? eq(assetFaces.personId, faceId) : undefined,
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ export default async function handler(
|
|||||||
faceCount: count(sql<string>`DISTINCT ${person.id}`), // Ensure unique personId
|
faceCount: count(sql<string>`DISTINCT ${person.id}`), // Ensure unique personId
|
||||||
})
|
})
|
||||||
.from(albums)
|
.from(albums)
|
||||||
.leftJoin(albumsAssetsAssets, eq(albums.id, albumsAssetsAssets.albumsId))
|
.leftJoin(albumsAssetsAssets, eq(albums.id, albumsAssetsAssets.albumId))
|
||||||
.leftJoin(assets, eq(albumsAssetsAssets.assetsId, assets.id))
|
.leftJoin(assets, eq(albumsAssetsAssets.assetId, assets.id))
|
||||||
.leftJoin(exif, and(eq(assets.id, exif.assetId), eq(assets.visibility, "timeline")))
|
.leftJoin(exif, and(eq(assets.id, exif.assetId), eq(assets.visibility, "timeline")))
|
||||||
.leftJoin(assetFaces, eq(assets.id, assetFaces.assetId))
|
.leftJoin(assetFaces, eq(assets.id, assetFaces.assetId))
|
||||||
.leftJoin(person, and(eq(assetFaces.personId, person.id), eq(person.isHidden, false)))
|
.leftJoin(person, and(eq(assetFaces.personId, person.id), eq(person.isHidden, false)))
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ export default async function handler(
|
|||||||
numberOfPhotos: count(assets.id),
|
numberOfPhotos: count(assets.id),
|
||||||
})
|
})
|
||||||
.from(albums)
|
.from(albums)
|
||||||
.leftJoin(albumsAssetsAssets, eq(albums.id, albumsAssetsAssets.albumsId))
|
.leftJoin(albumsAssetsAssets, eq(albums.id, albumsAssetsAssets.albumId))
|
||||||
.leftJoin(assets, eq(albumsAssetsAssets.assetsId, assets.id))
|
.leftJoin(assets, eq(albumsAssetsAssets.assetId, assets.id))
|
||||||
.leftJoin(assetFaces, eq(assets.id, assetFaces.assetId))
|
.leftJoin(assetFaces, eq(assets.id, assetFaces.assetId))
|
||||||
.leftJoin(person, and(eq(assetFaces.personId, person.id), eq(person.isHidden, false)))
|
.leftJoin(person, and(eq(assetFaces.personId, person.id), eq(person.isHidden, false)))
|
||||||
.where(and(eq(albums.ownerId, currentUser.id), eq(albums.id, id), isNotNull(person.id)))
|
.where(and(eq(albums.ownerId, currentUser.id), eq(albums.id, id), isNotNull(person.id)))
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ export default async function handler(
|
|||||||
faceCount: count(sql<string>`DISTINCT ${person.id}`), // Ensure unique personId
|
faceCount: count(sql<string>`DISTINCT ${person.id}`), // Ensure unique personId
|
||||||
})
|
})
|
||||||
.from(albums)
|
.from(albums)
|
||||||
.leftJoin(albumsAssetsAssets, eq(albums.id, albumsAssetsAssets.albumsId))
|
.leftJoin(albumsAssetsAssets, eq(albums.id, albumsAssetsAssets.albumId))
|
||||||
.leftJoin(assets, eq(albumsAssetsAssets.assetsId, assets.id))
|
.leftJoin(assets, eq(albumsAssetsAssets.assetId, assets.id))
|
||||||
.leftJoin(exif, and(eq(assets.id, exif.assetId), eq(assets.visibility, "timeline")))
|
.leftJoin(exif, and(eq(assets.id, exif.assetId), eq(assets.visibility, "timeline")))
|
||||||
.leftJoin(assetFaces, eq(assets.id, assetFaces.assetId))
|
.leftJoin(assetFaces, eq(assets.id, assetFaces.assetId))
|
||||||
.leftJoin(person, and(eq(assetFaces.personId, person.id), eq(person.isHidden, false)))
|
.leftJoin(person, and(eq(assetFaces.personId, person.id), eq(person.isHidden, false)))
|
||||||
|
|||||||
@@ -69,9 +69,9 @@ export default async function handler(
|
|||||||
faceCount: count(sql<string>`DISTINCT ${assetFaces.personId}`), // Ensure unique personId
|
faceCount: count(sql<string>`DISTINCT ${assetFaces.personId}`), // Ensure unique personId
|
||||||
})
|
})
|
||||||
.from(albums)
|
.from(albums)
|
||||||
.leftJoin(albumsAssetsAssets, eq(albums.id, albumsAssetsAssets.albumsId))
|
.leftJoin(albumsAssetsAssets, eq(albums.id, albumsAssetsAssets.albumId))
|
||||||
.leftJoin(assets, and(
|
.leftJoin(assets, and(
|
||||||
eq(albumsAssetsAssets.assetsId, assets.id),
|
eq(albumsAssetsAssets.assetId, assets.id),
|
||||||
eq(assets.visibility, "timeline"),
|
eq(assets.visibility, "timeline"),
|
||||||
eq(assets.status, "active"),
|
eq(assets.status, "active"),
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -61,13 +61,13 @@ export default async function handler(
|
|||||||
const secondaryAlbumAssets = await db
|
const secondaryAlbumAssets = await db
|
||||||
.select()
|
.select()
|
||||||
.from(albumsAssetsAssets)
|
.from(albumsAssetsAssets)
|
||||||
.where(inArray(albumsAssetsAssets.albumsId, secondaryAlbumIds));
|
.where(inArray(albumsAssetsAssets.albumId, secondaryAlbumIds));
|
||||||
|
|
||||||
if (secondaryAlbumAssets.length === 0) {
|
if (secondaryAlbumAssets.length === 0) {
|
||||||
return res.status(404).json({ error: "Secondary album assets not found" });
|
return res.status(404).json({ error: "Secondary album assets not found" });
|
||||||
}
|
}
|
||||||
|
|
||||||
const secondaryAlbumAssetsIds = secondaryAlbumAssets.map((albumAsset) => albumAsset.assetsId);
|
const secondaryAlbumAssetsIds = secondaryAlbumAssets.map((albumAsset) => albumAsset.assetId);
|
||||||
|
|
||||||
const addAssetsToPrimaryAlbumURL = `${ENV.IMMICH_URL}/api/albums/${primaryAlbumId}/assets`;
|
const addAssetsToPrimaryAlbumURL = `${ENV.IMMICH_URL}/api/albums/${primaryAlbumId}/assets`;
|
||||||
const addAssetsToPrimaryAlbum = await fetch(addAssetsToPrimaryAlbumURL, {
|
const addAssetsToPrimaryAlbum = await fetch(addAssetsToPrimaryAlbumURL, {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const SELECT_ORPHAN_PHOTOS = (date: string, ownerId: string) =>
|
|||||||
a."duration",
|
a."duration",
|
||||||
a."encodedVideoPath",
|
a."encodedVideoPath",
|
||||||
a."originalFileName",
|
a."originalFileName",
|
||||||
a."sidecarPath",
|
|
||||||
a."thumbhash",
|
a."thumbhash",
|
||||||
a."deletedAt",
|
a."deletedAt",
|
||||||
e."exifImageWidth",
|
e."exifImageWidth",
|
||||||
@@ -27,12 +27,12 @@ const SELECT_ORPHAN_PHOTOS = (date: string, ownerId: string) =>
|
|||||||
asset a
|
asset a
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
album_asset aaa
|
album_asset aaa
|
||||||
ON a.id = aaa."assetsId"
|
ON a.id = aaa."assetId"
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
asset_exif e
|
asset_exif e
|
||||||
ON a.id = e."assetId"
|
ON a.id = e."assetId"
|
||||||
WHERE
|
WHERE
|
||||||
aaa."albumsId" IS NULL
|
aaa."albumId" IS NULL
|
||||||
AND a."ownerId" = '${ownerId}'
|
AND a."ownerId" = '${ownerId}'
|
||||||
AND e."dateTimeOriginal"::date = '${date}'
|
AND e."dateTimeOriginal"::date = '${date}'
|
||||||
AND a."visibility" = 'timeline'
|
AND a."visibility" = 'timeline'
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ export default async function handler(
|
|||||||
date: sql`DATE(${exif.dateTimeOriginal})`,
|
date: sql`DATE(${exif.dateTimeOriginal})`,
|
||||||
asset_count: desc(count(assets.id)),
|
asset_count: desc(count(assets.id)),
|
||||||
}).from(assets)
|
}).from(assets)
|
||||||
.leftJoin(albumsAssetsAssets, eq(assets.id, albumsAssetsAssets.assetsId))
|
.leftJoin(albumsAssetsAssets, eq(assets.id, albumsAssetsAssets.assetId))
|
||||||
.leftJoin(exif, eq(assets.id, exif.assetId))
|
.leftJoin(exif, eq(assets.id, exif.assetId))
|
||||||
.where(and (
|
.where(and (
|
||||||
eq(assets.ownerId, currentUser.id),
|
eq(assets.ownerId, currentUser.id),
|
||||||
eq(assets.visibility, "timeline"),
|
eq(assets.visibility, "timeline"),
|
||||||
isNull(albumsAssetsAssets.albumsId),
|
isNull(albumsAssetsAssets.albumId),
|
||||||
isNotNull(exif.dateTimeOriginal),
|
isNotNull(exif.dateTimeOriginal),
|
||||||
|
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export default async function handler(
|
|||||||
value: count(sql`DISTINCT ${assets.id}`),
|
value: count(sql`DISTINCT ${assets.id}`),
|
||||||
})
|
})
|
||||||
.from(assets)
|
.from(assets)
|
||||||
.innerJoin(albumsAssetsAssets, eq(assets.id, albumsAssetsAssets.assetsId))
|
.innerJoin(albumsAssetsAssets, eq(assets.id, albumsAssetsAssets.assetId))
|
||||||
.where(eq(assets.ownerId, currentUser.id));
|
.where(eq(assets.ownerId, currentUser.id));
|
||||||
|
|
||||||
// Count total photos
|
// Count total photos
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ const dbAssets = await db
|
|||||||
duration: assets.duration,
|
duration: assets.duration,
|
||||||
encodedVideoPath: assets.encodedVideoPath,
|
encodedVideoPath: assets.encodedVideoPath,
|
||||||
originalFileName: assets.originalFileName,
|
originalFileName: assets.originalFileName,
|
||||||
sidecarPath: assets.sidecarPath,
|
|
||||||
deletedAt: assets.deletedAt,
|
deletedAt: assets.deletedAt,
|
||||||
localDateTime: assets.localDateTime,
|
localDateTime: assets.localDateTime,
|
||||||
exifImageWidth: exif.exifImageWidth,
|
exifImageWidth: exif.exifImageWidth,
|
||||||
|
|||||||
@@ -21,15 +21,15 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
longitude: exif.longitude,
|
longitude: exif.longitude,
|
||||||
}).from(assets)
|
}).from(assets)
|
||||||
.innerJoin(exif, eq(assets.id, exif.assetId))
|
.innerJoin(exif, eq(assets.id, exif.assetId))
|
||||||
.innerJoin(albumsAssetsAssets, eq(assets.id, albumsAssetsAssets.assetsId))
|
.innerJoin(albumsAssetsAssets, eq(assets.id, albumsAssetsAssets.assetId))
|
||||||
.innerJoin(assetFaces, eq(albumsAssetsAssets.assetsId, assetFaces.assetId))
|
.innerJoin(assetFaces, eq(albumsAssetsAssets.assetId, assetFaces.assetId))
|
||||||
.innerJoin(person, eq(assetFaces.personId, person.id))
|
.innerJoin(person, eq(assetFaces.personId, person.id))
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
eq(assets.ownerId, currentUser.id),
|
eq(assets.ownerId, currentUser.id),
|
||||||
isNotNull(exif.latitude),
|
isNotNull(exif.latitude),
|
||||||
isNotNull(exif.longitude),
|
isNotNull(exif.longitude),
|
||||||
albumIds?.length > 0 ? inArray(albumsAssetsAssets.albumsId, [albumIds]) : undefined,
|
albumIds?.length > 0 ? inArray(albumsAssetsAssets.albumId, [albumIds]) : undefined,
|
||||||
peopleIds?.length > 0 ? inArray(person.id, [peopleIds]) : undefined
|
peopleIds?.length > 0 ? inArray(person.id, [peopleIds]) : undefined
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ export default async function handler(
|
|||||||
})
|
})
|
||||||
.from(assets)
|
.from(assets)
|
||||||
.leftJoin(exif, eq(exif.assetId, assets.id))
|
.leftJoin(exif, eq(exif.assetId, assets.id))
|
||||||
.leftJoin(albumsAssetsAssets, eq(albumsAssetsAssets.assetsId, assets.id))
|
.leftJoin(albumsAssetsAssets, eq(albumsAssetsAssets.assetId, assets.id))
|
||||||
.leftJoin(albums, eq(albums.id, albumsAssetsAssets.albumsId))
|
.leftJoin(albums, eq(albums.id, albumsAssetsAssets.albumId))
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
isNull(exif.latitude),
|
isNull(exif.latitude),
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ const getRowsByDates = async (startDateDate: Date, endDateDate: Date, currentUse
|
|||||||
duration: assets.duration,
|
duration: assets.duration,
|
||||||
encodedVideoPath: assets.encodedVideoPath,
|
encodedVideoPath: assets.encodedVideoPath,
|
||||||
originalFileName: assets.originalFileName,
|
originalFileName: assets.originalFileName,
|
||||||
sidecarPath: assets.sidecarPath,
|
|
||||||
deletedAt: assets.deletedAt,
|
deletedAt: assets.deletedAt,
|
||||||
localDateTime: assets.localDateTime,
|
localDateTime: assets.localDateTime,
|
||||||
exifImageWidth: exif.exifImageWidth,
|
exifImageWidth: exif.exifImageWidth,
|
||||||
@@ -55,7 +55,7 @@ const getRowsByAlbums = async (currentUser: IUser, albumId: string) => {
|
|||||||
duration: assets.duration,
|
duration: assets.duration,
|
||||||
encodedVideoPath: assets.encodedVideoPath,
|
encodedVideoPath: assets.encodedVideoPath,
|
||||||
originalFileName: assets.originalFileName,
|
originalFileName: assets.originalFileName,
|
||||||
sidecarPath: assets.sidecarPath,
|
|
||||||
deletedAt: assets.deletedAt,
|
deletedAt: assets.deletedAt,
|
||||||
localDateTime: assets.localDateTime,
|
localDateTime: assets.localDateTime,
|
||||||
exifImageWidth: exif.exifImageWidth,
|
exifImageWidth: exif.exifImageWidth,
|
||||||
@@ -66,8 +66,8 @@ const getRowsByAlbums = async (currentUser: IUser, albumId: string) => {
|
|||||||
})
|
})
|
||||||
.from(assets)
|
.from(assets)
|
||||||
.leftJoin(exif, eq(exif.assetId, assets.id))
|
.leftJoin(exif, eq(exif.assetId, assets.id))
|
||||||
.leftJoin(albumsAssetsAssets, eq(albumsAssetsAssets.assetsId, assets.id))
|
.leftJoin(albumsAssetsAssets, eq(albumsAssetsAssets.assetId, assets.id))
|
||||||
.leftJoin(albums, eq(albums.id, albumsAssetsAssets.albumsId))
|
.leftJoin(albums, eq(albums.id, albumsAssetsAssets.albumId))
|
||||||
.where(and(
|
.where(and(
|
||||||
isNull(exif.latitude),
|
isNull(exif.latitude),
|
||||||
isNotNull(assets.createdAt),
|
isNotNull(assets.createdAt),
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
.leftJoin(assetFaces, eq(assetFaces.personId, personRecord.id))
|
.leftJoin(assetFaces, eq(assetFaces.personId, personRecord.id))
|
||||||
.leftJoin(assets, eq(assets.id, assetFaces.assetId))
|
.leftJoin(assets, eq(assets.id, assetFaces.assetId))
|
||||||
.leftJoin(exif, eq(exif.assetId, assets.id))
|
.leftJoin(exif, eq(exif.assetId, assets.id))
|
||||||
.leftJoin(albumsAssetsAssets, eq(albumsAssetsAssets.assetsId, assets.id))
|
.leftJoin(albumsAssetsAssets, eq(albumsAssetsAssets.assetId, assets.id))
|
||||||
.where(eq(albumsAssetsAssets.albumsId, albums.id))
|
.where(eq(albumsAssetsAssets.albumId, albums.id))
|
||||||
.groupBy(albums.id);
|
.groupBy(albums.id);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
cover: albums.albumThumbnailAssetId
|
cover: albums.albumThumbnailAssetId
|
||||||
})
|
})
|
||||||
.from(albumsAssetsAssets)
|
.from(albumsAssetsAssets)
|
||||||
.leftJoin(albums, eq(albums.id, albumsAssetsAssets.albumsId))
|
.leftJoin(albums, eq(albums.id, albumsAssetsAssets.albumId))
|
||||||
.leftJoin(assets, eq(assets.id, albumsAssetsAssets.assetsId))
|
.leftJoin(assets, eq(assets.id, albumsAssetsAssets.assetId))
|
||||||
.leftJoin(exif, eq(exif.assetId, assets.id))
|
.leftJoin(exif, eq(exif.assetId, assets.id))
|
||||||
.where(and(
|
.where(and(
|
||||||
eq(sql`EXTRACT(YEAR FROM ${exif.dateTimeOriginal})`, year),
|
eq(sql`EXTRACT(YEAR FROM ${exif.dateTimeOriginal})`, year),
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
duration: assets.duration,
|
duration: assets.duration,
|
||||||
encodedVideoPath: assets.encodedVideoPath,
|
encodedVideoPath: assets.encodedVideoPath,
|
||||||
originalFileName: assets.originalFileName,
|
originalFileName: assets.originalFileName,
|
||||||
sidecarPath: assets.sidecarPath,
|
|
||||||
deletedAt: assets.deletedAt,
|
deletedAt: assets.deletedAt,
|
||||||
localDateTime: assets.localDateTime,
|
localDateTime: assets.localDateTime,
|
||||||
exifImageWidth: exif.exifImageWidth,
|
exifImageWidth: exif.exifImageWidth,
|
||||||
@@ -76,8 +76,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
orientation: exif.orientation,
|
orientation: exif.orientation,
|
||||||
}).from(assets)
|
}).from(assets)
|
||||||
.innerJoin(assetFaces, eq(assets.id, assetFaces.assetId))
|
.innerJoin(assetFaces, eq(assets.id, assetFaces.assetId))
|
||||||
.leftJoin(albumsAssetsAssets, eq(assets.id, albumsAssetsAssets.assetsId))
|
.leftJoin(albumsAssetsAssets, eq(assets.id, albumsAssetsAssets.assetId))
|
||||||
.leftJoin(albums, eq(albumsAssetsAssets.albumsId, albums.id))
|
.leftJoin(albums, eq(albumsAssetsAssets.albumId, albums.id))
|
||||||
.innerJoin(exif, eq(exif.assetId, assets.id))
|
.innerJoin(exif, eq(exif.assetId, assets.id))
|
||||||
.where(and(
|
.where(and(
|
||||||
filteredPersonIds?.length > 0 ? inArray(assetFaces.personId, filteredPersonIds) : undefined,
|
filteredPersonIds?.length > 0 ? inArray(assetFaces.personId, filteredPersonIds) : undefined,
|
||||||
|
|||||||
@@ -44,9 +44,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
assetCount: count(assets.id),
|
assetCount: count(assets.id),
|
||||||
}).from(assets)
|
}).from(assets)
|
||||||
.innerJoin(assetFaces, eq(assets.id, assetFaces.assetId))
|
.innerJoin(assetFaces, eq(assets.id, assetFaces.assetId))
|
||||||
.innerJoin(albumsAssetsAssets, eq(assets.id, albumsAssetsAssets.assetsId))
|
.innerJoin(albumsAssetsAssets, eq(assets.id, albumsAssetsAssets.assetId))
|
||||||
.innerJoin(person, eq(assetFaces.personId, person.id))
|
.innerJoin(person, eq(assetFaces.personId, person.id))
|
||||||
.innerJoin(albums, eq(albumsAssetsAssets.albumsId, albums.id))
|
.innerJoin(albums, eq(albumsAssetsAssets.albumId, albums.id))
|
||||||
.innerJoin(exif, eq(exif.assetId, assets.id))
|
.innerJoin(exif, eq(exif.assetId, assets.id))
|
||||||
.where(and(
|
.where(and(
|
||||||
personIds?.length > 0 ? inArray(assetFaces.personId, personIds) : undefined,
|
personIds?.length > 0 ? inArray(assetFaces.personId, personIds) : undefined,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { pgTable, uuid, timestamp } from 'drizzle-orm/pg-core';
|
import { pgTable, uuid, timestamp } from 'drizzle-orm/pg-core';
|
||||||
|
|
||||||
export const albumsAssetsAssets = pgTable('album_asset', {
|
export const albumsAssetsAssets = pgTable('album_asset', {
|
||||||
albumsId: uuid('albumsId').notNull(),
|
albumId: uuid("albumId").notNull(),
|
||||||
assetsId: uuid('assetsId').notNull(),
|
assetId: uuid("assetId").notNull(),
|
||||||
createdAt: timestamp('createdAt', { withTimezone: true }).defaultNow().notNull(),
|
createdAt: timestamp('createdAt', { withTimezone: true }).defaultNow().notNull(),
|
||||||
});
|
});
|
||||||
@@ -19,7 +19,6 @@ export const assets = pgTable('asset', {
|
|||||||
createdAt: timestamp('createdAt', { withTimezone: true }).defaultNow().notNull(),
|
createdAt: timestamp('createdAt', { withTimezone: true }).defaultNow().notNull(),
|
||||||
status: varchar('status').default('active').notNull(),
|
status: varchar('status').default('active').notNull(),
|
||||||
originalFileName: varchar('originalFileName').notNull(),
|
originalFileName: varchar('originalFileName').notNull(),
|
||||||
sidecarPath: varchar('sidecarPath'),
|
|
||||||
// thumbhash: bytea('thumbhash'),
|
// thumbhash: bytea('thumbhash'),
|
||||||
isOffline: boolean('isOffline').default(false).notNull(),
|
isOffline: boolean('isOffline').default(false).notNull(),
|
||||||
// libraryId: uuid('libraryId').references(() => libraries.id, { onDelete: 'cascade', onUpdate: 'cascade' }),
|
// libraryId: uuid('libraryId').references(() => libraries.id, { onDelete: 'cascade', onUpdate: 'cascade' }),
|
||||||
|
|||||||
@@ -44,11 +44,11 @@ export const faceSearchRelations = relations(faceSearch, ({ one }) => ({
|
|||||||
// Assuming there are relations to be defined with `albums` and `assets`
|
// Assuming there are relations to be defined with `albums` and `assets`
|
||||||
export const albumsAssetsAssetsRelations = relations(albumsAssetsAssets, ({ one }) => ({
|
export const albumsAssetsAssetsRelations = relations(albumsAssetsAssets, ({ one }) => ({
|
||||||
album: one(albums, {
|
album: one(albums, {
|
||||||
fields: [albumsAssetsAssets.albumsId],
|
fields: [albumsAssetsAssets.albumId],
|
||||||
references: [albums.id],
|
references: [albums.id],
|
||||||
}),
|
}),
|
||||||
asset: one(assets, {
|
asset: one(assets, {
|
||||||
fields: [albumsAssetsAssets.assetsId],
|
fields: [albumsAssetsAssets.assetId],
|
||||||
references: [assets.id],
|
references: [assets.id],
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in new issue
Block a user