feat: rename schema (#19891)

This commit is contained in:
Jason Rasmussen
2025-07-14 10:13:06 -04:00
committed by GitHub
parent 33c29e4305
commit c699df002a
103 changed files with 4378 additions and 3224 deletions

View File

@@ -14,161 +14,161 @@ select
"activity"."id"
from
"activity"
left join "albums" on "activity"."albumId" = "albums"."id"
and "albums"."deletedAt" is null
left join "album" on "activity"."albumId" = "album"."id"
and "album"."deletedAt" is null
where
"activity"."id" in ($1)
and "albums"."ownerId" = $2::uuid
and "album"."ownerId" = $2::uuid
-- AccessRepository.activity.checkCreateAccess
select
"albums"."id"
"album"."id"
from
"albums"
left join "albums_shared_users_users" as "albumUsers" on "albumUsers"."albumsId" = "albums"."id"
left join "users" on "users"."id" = "albumUsers"."usersId"
and "users"."deletedAt" is null
"album"
left join "album_user" as "albumUsers" on "albumUsers"."albumsId" = "album"."id"
left join "user" on "user"."id" = "albumUsers"."usersId"
and "user"."deletedAt" is null
where
"albums"."id" in ($1)
and "albums"."isActivityEnabled" = $2
"album"."id" in ($1)
and "album"."isActivityEnabled" = $2
and (
"albums"."ownerId" = $3
or "users"."id" = $4
"album"."ownerId" = $3
or "user"."id" = $4
)
and "albums"."deletedAt" is null
and "album"."deletedAt" is null
-- AccessRepository.album.checkOwnerAccess
select
"albums"."id"
"album"."id"
from
"albums"
"album"
where
"albums"."id" in ($1)
and "albums"."ownerId" = $2
and "albums"."deletedAt" is null
"album"."id" in ($1)
and "album"."ownerId" = $2
and "album"."deletedAt" is null
-- AccessRepository.album.checkSharedAlbumAccess
select
"albums"."id"
"album"."id"
from
"albums"
left join "albums_shared_users_users" as "albumUsers" on "albumUsers"."albumsId" = "albums"."id"
left join "users" on "users"."id" = "albumUsers"."usersId"
and "users"."deletedAt" is null
"album"
left join "album_user" on "album_user"."albumsId" = "album"."id"
left join "user" on "user"."id" = "album_user"."usersId"
and "user"."deletedAt" is null
where
"albums"."id" in ($1)
and "albums"."deletedAt" is null
and "users"."id" = $2
and "albumUsers"."role" in ($3, $4)
"album"."id" in ($1)
and "album"."deletedAt" is null
and "user"."id" = $2
and "album_user"."role" in ($3, $4)
-- AccessRepository.album.checkSharedLinkAccess
select
"shared_links"."albumId"
"shared_link"."albumId"
from
"shared_links"
"shared_link"
where
"shared_links"."id" = $1
and "shared_links"."albumId" in ($2)
"shared_link"."id" = $1
and "shared_link"."albumId" in ($2)
-- AccessRepository.asset.checkAlbumAccess
select
"assets"."id",
"assets"."livePhotoVideoId"
"asset"."id",
"asset"."livePhotoVideoId"
from
"albums"
inner join "albums_assets_assets" as "albumAssets" on "albums"."id" = "albumAssets"."albumsId"
inner join "assets" on "assets"."id" = "albumAssets"."assetsId"
and "assets"."deletedAt" is null
left join "albums_shared_users_users" as "albumUsers" on "albumUsers"."albumsId" = "albums"."id"
left join "users" on "users"."id" = "albumUsers"."usersId"
and "users"."deletedAt" is null
"album"
inner join "album_asset" as "albumAssets" on "album"."id" = "albumAssets"."albumsId"
inner join "asset" on "asset"."id" = "albumAssets"."assetsId"
and "asset"."deletedAt" is null
left join "album_user" as "albumUsers" on "albumUsers"."albumsId" = "album"."id"
left join "user" on "user"."id" = "albumUsers"."usersId"
and "user"."deletedAt" is null
where
array["assets"."id", "assets"."livePhotoVideoId"] && array[$1]::uuid[]
array["asset"."id", "asset"."livePhotoVideoId"] && array[$1]::uuid[]
and (
"albums"."ownerId" = $2
or "users"."id" = $3
"album"."ownerId" = $2
or "user"."id" = $3
)
and "albums"."deletedAt" is null
and "album"."deletedAt" is null
-- AccessRepository.asset.checkOwnerAccess
select
"assets"."id"
"asset"."id"
from
"assets"
"asset"
where
"assets"."id" in ($1)
and "assets"."ownerId" = $2
and "assets"."visibility" != $3
"asset"."id" in ($1)
and "asset"."ownerId" = $2
and "asset"."visibility" != $3
-- AccessRepository.asset.checkPartnerAccess
select
"assets"."id"
"asset"."id"
from
"partners" as "partner"
inner join "users" as "sharedBy" on "sharedBy"."id" = "partner"."sharedById"
"partner"
inner join "user" as "sharedBy" on "sharedBy"."id" = "partner"."sharedById"
and "sharedBy"."deletedAt" is null
inner join "assets" on "assets"."ownerId" = "sharedBy"."id"
and "assets"."deletedAt" is null
inner join "asset" on "asset"."ownerId" = "sharedBy"."id"
and "asset"."deletedAt" is null
where
"partner"."sharedWithId" = $1
and (
"assets"."visibility" = 'timeline'
or "assets"."visibility" = 'hidden'
"asset"."visibility" = 'timeline'
or "asset"."visibility" = 'hidden'
)
and "assets"."id" in ($2)
and "asset"."id" in ($2)
-- AccessRepository.asset.checkSharedLinkAccess
select
"assets"."id" as "assetId",
"assets"."livePhotoVideoId" as "assetLivePhotoVideoId",
"asset"."id" as "assetId",
"asset"."livePhotoVideoId" as "assetLivePhotoVideoId",
"albumAssets"."id" as "albumAssetId",
"albumAssets"."livePhotoVideoId" as "albumAssetLivePhotoVideoId"
from
"shared_links"
left join "albums" on "albums"."id" = "shared_links"."albumId"
and "albums"."deletedAt" is null
left join "shared_link__asset" on "shared_link__asset"."sharedLinksId" = "shared_links"."id"
left join "assets" on "assets"."id" = "shared_link__asset"."assetsId"
and "assets"."deletedAt" is null
left join "albums_assets_assets" on "albums_assets_assets"."albumsId" = "albums"."id"
left join "assets" as "albumAssets" on "albumAssets"."id" = "albums_assets_assets"."assetsId"
"shared_link"
left join "album" on "album"."id" = "shared_link"."albumId"
and "album"."deletedAt" is null
left join "shared_link_asset" on "shared_link_asset"."sharedLinksId" = "shared_link"."id"
left join "asset" on "asset"."id" = "shared_link_asset"."assetsId"
and "asset"."deletedAt" is null
left join "album_asset" on "album_asset"."albumsId" = "album"."id"
left join "asset" as "albumAssets" on "albumAssets"."id" = "album_asset"."assetsId"
and "albumAssets"."deletedAt" is null
where
"shared_links"."id" = $1
"shared_link"."id" = $1
and array[
"assets"."id",
"assets"."livePhotoVideoId",
"asset"."id",
"asset"."livePhotoVideoId",
"albumAssets"."id",
"albumAssets"."livePhotoVideoId"
] && array[$2]::uuid[]
-- AccessRepository.authDevice.checkOwnerAccess
select
"sessions"."id"
"session"."id"
from
"sessions"
"session"
where
"sessions"."userId" = $1
and "sessions"."id" in ($2)
"session"."userId" = $1
and "session"."id" in ($2)
-- AccessRepository.memory.checkOwnerAccess
select
"memories"."id"
"memory"."id"
from
"memories"
"memory"
where
"memories"."id" in ($1)
and "memories"."ownerId" = $2
and "memories"."deletedAt" is null
"memory"."id" in ($1)
and "memory"."ownerId" = $2
and "memory"."deletedAt" is null
-- AccessRepository.notification.checkOwnerAccess
select
"notifications"."id"
"notification"."id"
from
"notifications"
"notification"
where
"notifications"."id" in ($1)
and "notifications"."userId" = $2
"notification"."id" in ($1)
and "notification"."userId" = $2
-- AccessRepository.person.checkOwnerAccess
select
@@ -181,56 +181,56 @@ where
-- AccessRepository.person.checkFaceOwnerAccess
select
"asset_faces"."id"
"asset_face"."id"
from
"asset_faces"
left join "assets" on "assets"."id" = "asset_faces"."assetId"
and "assets"."deletedAt" is null
"asset_face"
left join "asset" on "asset"."id" = "asset_face"."assetId"
and "asset"."deletedAt" is null
where
"asset_faces"."id" in ($1)
and "assets"."ownerId" = $2
"asset_face"."id" in ($1)
and "asset"."ownerId" = $2
-- AccessRepository.partner.checkUpdateAccess
select
"partners"."sharedById"
"partner"."sharedById"
from
"partners"
"partner"
where
"partners"."sharedById" in ($1)
and "partners"."sharedWithId" = $2
"partner"."sharedById" in ($1)
and "partner"."sharedWithId" = $2
-- AccessRepository.session.checkOwnerAccess
select
"sessions"."id"
"session"."id"
from
"sessions"
"session"
where
"sessions"."id" in ($1)
and "sessions"."userId" = $2
"session"."id" in ($1)
and "session"."userId" = $2
-- AccessRepository.stack.checkOwnerAccess
select
"stacks"."id"
"stack"."id"
from
"asset_stack" as "stacks"
"stack"
where
"stacks"."id" in ($1)
and "stacks"."ownerId" = $2
"stack"."id" in ($1)
and "stack"."ownerId" = $2
-- AccessRepository.tag.checkOwnerAccess
select
"tags"."id"
"tag"."id"
from
"tags"
"tag"
where
"tags"."id" in ($1)
and "tags"."userId" = $2
"tag"."id" in ($1)
and "tag"."userId" = $2
-- AccessRepository.timeline.checkPartnerAccess
select
"partners"."sharedById"
"partner"."sharedById"
from
"partners"
"partner"
where
"partners"."sharedById" in ($1)
and "partners"."sharedWithId" = $2
"partner"."sharedById" in ($1)
and "partner"."sharedWithId" = $2

View File

@@ -6,26 +6,26 @@ select
to_json("user") as "user"
from
"activity"
inner join "users" on "users"."id" = "activity"."userId"
and "users"."deletedAt" is null
inner join "user" as "user2" on "user2"."id" = "activity"."userId"
and "user2"."deletedAt" is null
inner join lateral (
select
"users"."id",
"users"."name",
"users"."email",
"users"."avatarColor",
"users"."profileImagePath",
"users"."profileChangedAt"
"user2"."id",
"user2"."name",
"user2"."email",
"user2"."avatarColor",
"user2"."profileImagePath",
"user2"."profileChangedAt"
from
(
select
1
) as "dummy"
) as "user" on true
left join "assets" on "assets"."id" = "activity"."assetId"
left join "asset" on "asset"."id" = "activity"."assetId"
where
"activity"."albumId" = $1
and "assets"."deletedAt" is null
and "asset"."deletedAt" is null
order by
"activity"."createdAt" asc
@@ -49,9 +49,9 @@ returning
"profileImagePath",
"profileChangedAt"
from
"users"
"user"
where
"users"."id" = "activity"."userId"
"user"."id" = "activity"."userId"
) as obj
) as "user"
@@ -72,16 +72,16 @@ select
) as "likes"
from
"activity"
inner join "users" on "users"."id" = "activity"."userId"
and "users"."deletedAt" is null
left join "assets" on "assets"."id" = "activity"."assetId"
inner join "user" on "user"."id" = "activity"."userId"
and "user"."deletedAt" is null
left join "asset" on "asset"."id" = "activity"."assetId"
where
"activity"."assetId" = $3
and "activity"."albumId" = $4
and (
(
"assets"."deletedAt" is null
and "assets"."visibility" != 'locked'
"asset"."deletedAt" is null
and "asset"."visibility" != 'locked'
)
or "assets"."id" is null
or "asset"."id" is null
)

View File

@@ -2,7 +2,7 @@
-- AlbumRepository.getById
select
"albums".*,
"album".*,
(
select
to_json(obj)
@@ -16,9 +16,9 @@ select
"profileImagePath",
"profileChangedAt"
from
"users"
"user"
where
"users"."id" = "albums"."ownerId"
"user"."id" = "album"."ownerId"
) as obj
) as "owner",
(
@@ -27,7 +27,7 @@ select
from
(
select
"album_users"."role",
"album_user"."role",
(
select
to_json(obj)
@@ -41,15 +41,15 @@ select
"profileImagePath",
"profileChangedAt"
from
"users"
"user"
where
"users"."id" = "album_users"."usersId"
"user"."id" = "album_user"."usersId"
) as obj
) as "user"
from
"albums_shared_users_users" as "album_users"
"album_user"
where
"album_users"."albumsId" = "albums"."id"
"album_user"."albumsId" = "album"."id"
) as agg
) as "albumUsers",
(
@@ -60,9 +60,9 @@ select
select
*
from
"shared_links"
"shared_link"
where
"shared_links"."albumId" = "albums"."id"
"shared_link"."albumId" = "album"."id"
) as agg
) as "sharedLinks",
(
@@ -71,29 +71,29 @@ select
from
(
select
"assets".*,
"exif" as "exifInfo"
"asset".*,
"asset_exif" as "exifInfo"
from
"assets"
left join "exif" on "assets"."id" = "exif"."assetId"
inner join "albums_assets_assets" on "albums_assets_assets"."assetsId" = "assets"."id"
"asset"
left join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
inner join "album_asset" on "album_asset"."assetsId" = "asset"."id"
where
"albums_assets_assets"."albumsId" = "albums"."id"
and "assets"."deletedAt" is null
and "assets"."visibility" in ('archive', 'timeline')
"album_asset"."albumsId" = "album"."id"
and "asset"."deletedAt" is null
and "asset"."visibility" in ('archive', 'timeline')
order by
"assets"."fileCreatedAt" desc
"asset"."fileCreatedAt" desc
) as "asset"
) as "assets"
from
"albums"
"album"
where
"albums"."id" = $1
and "albums"."deletedAt" is null
"album"."id" = $1
and "album"."deletedAt" is null
-- AlbumRepository.getByAssetId
select
"albums".*,
"album".*,
(
select
to_json(obj)
@@ -107,9 +107,9 @@ select
"profileImagePath",
"profileChangedAt"
from
"users"
"user"
where
"users"."id" = "albums"."ownerId"
"user"."id" = "album"."ownerId"
) as obj
) as "owner",
(
@@ -118,7 +118,7 @@ select
from
(
select
"album_users"."role",
"album_user"."role",
(
select
to_json(obj)
@@ -132,62 +132,62 @@ select
"profileImagePath",
"profileChangedAt"
from
"users"
"user"
where
"users"."id" = "album_users"."usersId"
"user"."id" = "album_user"."usersId"
) as obj
) as "user"
from
"albums_shared_users_users" as "album_users"
"album_user"
where
"album_users"."albumsId" = "albums"."id"
"album_user"."albumsId" = "album"."id"
) as agg
) as "albumUsers"
from
"albums"
inner join "albums_assets_assets" as "album_assets" on "album_assets"."albumsId" = "albums"."id"
"album"
inner join "album_asset" on "album_asset"."albumsId" = "album"."id"
where
(
"albums"."ownerId" = $1
"album"."ownerId" = $1
or exists (
select
from
"albums_shared_users_users" as "album_users"
"album_user"
where
"album_users"."albumsId" = "albums"."id"
and "album_users"."usersId" = $2
"album_user"."albumsId" = "album"."id"
and "album_user"."usersId" = $2
)
)
and "album_assets"."assetsId" = $3
and "albums"."deletedAt" is null
and "album_asset"."assetsId" = $3
and "album"."deletedAt" is null
order by
"albums"."createdAt" desc,
"albums"."createdAt" desc
"album"."createdAt" desc,
"album"."createdAt" desc
-- AlbumRepository.getMetadataForIds
select
"album_assets"."albumsId" as "albumId",
"album_asset"."albumsId" as "albumId",
min(
("assets"."localDateTime" AT TIME ZONE 'UTC'::text)::date
("asset"."localDateTime" AT TIME ZONE 'UTC'::text)::date
) as "startDate",
max(
("assets"."localDateTime" AT TIME ZONE 'UTC'::text)::date
("asset"."localDateTime" AT TIME ZONE 'UTC'::text)::date
) as "endDate",
max("assets"."updatedAt") as "lastModifiedAssetTimestamp",
count("assets"."id")::int as "assetCount"
max("asset"."updatedAt") as "lastModifiedAssetTimestamp",
count("asset"."id")::int as "assetCount"
from
"assets"
inner join "albums_assets_assets" as "album_assets" on "album_assets"."assetsId" = "assets"."id"
"asset"
inner join "album_asset" on "album_asset"."assetsId" = "asset"."id"
where
"assets"."visibility" in ('archive', 'timeline')
and "album_assets"."albumsId" in ($1)
and "assets"."deletedAt" is null
"asset"."visibility" in ('archive', 'timeline')
and "album_asset"."albumsId" in ($1)
and "asset"."deletedAt" is null
group by
"album_assets"."albumsId"
"album_asset"."albumsId"
-- AlbumRepository.getOwned
select
"albums".*,
"album".*,
(
select
to_json(obj)
@@ -201,9 +201,9 @@ select
"profileImagePath",
"profileChangedAt"
from
"users"
"user"
where
"users"."id" = "albums"."ownerId"
"user"."id" = "album"."ownerId"
) as obj
) as "owner",
(
@@ -212,7 +212,7 @@ select
from
(
select
"album_users"."role",
"album_user"."role",
(
select
to_json(obj)
@@ -226,15 +226,15 @@ select
"profileImagePath",
"profileChangedAt"
from
"users"
"user"
where
"users"."id" = "album_users"."usersId"
"user"."id" = "album_user"."usersId"
) as obj
) as "user"
from
"albums_shared_users_users" as "album_users"
"album_user"
where
"album_users"."albumsId" = "albums"."id"
"album_user"."albumsId" = "album"."id"
) as agg
) as "albumUsers",
(
@@ -245,29 +245,29 @@ select
select
*
from
"shared_links"
"shared_link"
where
"shared_links"."albumId" = "albums"."id"
"shared_link"."albumId" = "album"."id"
) as agg
) as "sharedLinks"
from
"albums"
"album"
where
"albums"."ownerId" = $1
and "albums"."deletedAt" is null
"album"."ownerId" = $1
and "album"."deletedAt" is null
order by
"albums"."createdAt" desc
"album"."createdAt" desc
-- AlbumRepository.getShared
select
"albums".*,
"album".*,
(
select
coalesce(json_agg(agg), '[]')
from
(
select
"album_users"."role",
"album_user"."role",
(
select
to_json(obj)
@@ -281,15 +281,15 @@ select
"profileImagePath",
"profileChangedAt"
from
"users"
"user"
where
"users"."id" = "album_users"."usersId"
"user"."id" = "album_user"."usersId"
) as obj
) as "user"
from
"albums_shared_users_users" as "album_users"
"album_user"
where
"album_users"."albumsId" = "albums"."id"
"album_user"."albumsId" = "album"."id"
) as agg
) as "albumUsers",
(
@@ -305,9 +305,9 @@ select
"profileImagePath",
"profileChangedAt"
from
"users"
"user"
where
"users"."id" = "albums"."ownerId"
"user"."id" = "album"."ownerId"
) as obj
) as "owner",
(
@@ -318,42 +318,42 @@ select
select
*
from
"shared_links"
"shared_link"
where
"shared_links"."albumId" = "albums"."id"
"shared_link"."albumId" = "album"."id"
) as agg
) as "sharedLinks"
from
"albums"
"album"
where
(
exists (
select
from
"albums_shared_users_users" as "album_users"
"album_user"
where
"album_users"."albumsId" = "albums"."id"
"album_user"."albumsId" = "album"."id"
and (
"albums"."ownerId" = $1
or "album_users"."usersId" = $2
"album"."ownerId" = $1
or "album_user"."usersId" = $2
)
)
or exists (
select
from
"shared_links"
"shared_link"
where
"shared_links"."albumId" = "albums"."id"
and "shared_links"."userId" = $3
"shared_link"."albumId" = "album"."id"
and "shared_link"."userId" = $3
)
)
and "albums"."deletedAt" is null
and "album"."deletedAt" is null
order by
"albums"."createdAt" desc
"album"."createdAt" desc
-- AlbumRepository.getNotShared
select
"albums".*,
"album".*,
(
select
to_json(obj)
@@ -367,43 +367,43 @@ select
"profileImagePath",
"profileChangedAt"
from
"users"
"user"
where
"users"."id" = "albums"."ownerId"
"user"."id" = "album"."ownerId"
) as obj
) as "owner"
from
"albums"
"album"
where
"albums"."ownerId" = $1
and "albums"."deletedAt" is null
"album"."ownerId" = $1
and "album"."deletedAt" is null
and not exists (
select
from
"albums_shared_users_users" as "album_users"
"album_user"
where
"album_users"."albumsId" = "albums"."id"
"album_user"."albumsId" = "album"."id"
)
and not exists (
select
from
"shared_links"
"shared_link"
where
"shared_links"."albumId" = "albums"."id"
"shared_link"."albumId" = "album"."id"
)
order by
"albums"."createdAt" desc
"album"."createdAt" desc
-- AlbumRepository.removeAssetsFromAll
delete from "albums_assets_assets"
delete from "album_asset"
where
"albums_assets_assets"."assetsId" in ($1)
"album_asset"."assetsId" in ($1)
-- AlbumRepository.getAssetIds
select
*
from
"albums_assets_assets"
"album_asset"
where
"albums_assets_assets"."albumsId" = $1
and "albums_assets_assets"."assetsId" in ($2)
"album_asset"."albumsId" = $1
and "album_asset"."assetsId" in ($2)

View File

@@ -2,7 +2,7 @@
-- AlbumUserRepository.create
insert into
"albums_shared_users_users" ("usersId", "albumsId")
"album_user" ("usersId", "albumsId")
values
($1, $2)
returning
@@ -11,7 +11,7 @@ returning
"role"
-- AlbumUserRepository.update
update "albums_shared_users_users"
update "album_user"
set
"role" = $1
where
@@ -21,7 +21,7 @@ returning
*
-- AlbumUserRepository.delete
delete from "albums_shared_users_users"
delete from "album_user"
where
"usersId" = $1
and "albumsId" = $2

View File

@@ -2,31 +2,31 @@
-- ApiKeyRepository.getKey
select
"api_keys"."id",
"api_keys"."permissions",
"api_key"."id",
"api_key"."permissions",
(
select
to_json(obj)
from
(
select
"users"."id",
"users"."name",
"users"."email",
"users"."isAdmin",
"users"."quotaUsageInBytes",
"users"."quotaSizeInBytes"
"user"."id",
"user"."name",
"user"."email",
"user"."isAdmin",
"user"."quotaUsageInBytes",
"user"."quotaSizeInBytes"
from
"users"
"user"
where
"users"."id" = "api_keys"."userId"
and "users"."deletedAt" is null
"user"."id" = "api_key"."userId"
and "user"."deletedAt" is null
) as obj
) as "user"
from
"api_keys"
"api_key"
where
"api_keys"."key" = $1
"api_key"."key" = $1
-- ApiKeyRepository.getById
select
@@ -37,7 +37,7 @@ select
"updatedAt",
"permissions"
from
"api_keys"
"api_key"
where
"id" = $1::uuid
and "userId" = $2
@@ -51,7 +51,7 @@ select
"updatedAt",
"permissions"
from
"api_keys"
"api_key"
where
"userId" = $1
order by

View File

@@ -10,10 +10,10 @@ select
"visibility",
"smart_search"."embedding"
from
"assets"
left join "smart_search" on "assets"."id" = "smart_search"."assetId"
"asset"
left join "smart_search" on "asset"."id" = "smart_search"."assetId"
where
"assets"."id" = $1::uuid
"asset"."id" = $1::uuid
limit
$2
@@ -28,227 +28,227 @@ select
from
(
select
"tags"."value"
"tag"."value"
from
"tags"
inner join "tag_asset" on "tags"."id" = "tag_asset"."tagsId"
"tag"
inner join "tag_asset" on "tag"."id" = "tag_asset"."tagsId"
where
"assets"."id" = "tag_asset"."assetsId"
"asset"."id" = "tag_asset"."assetsId"
) as agg
) as "tags"
from
"assets"
"asset"
where
"assets"."id" = $1::uuid
"asset"."id" = $1::uuid
limit
$2
-- AssetJobRepository.streamForThumbnailJob
select
"assets"."id",
"assets"."thumbhash",
"asset"."id",
"asset"."thumbhash",
(
select
coalesce(json_agg(agg), '[]')
from
(
select
"asset_files"."id",
"asset_files"."path",
"asset_files"."type"
"asset_file"."id",
"asset_file"."path",
"asset_file"."type"
from
"asset_files"
"asset_file"
where
"asset_files"."assetId" = "assets"."id"
"asset_file"."assetId" = "asset"."id"
) as agg
) as "files"
from
"assets"
inner join "asset_job_status" on "asset_job_status"."assetId" = "assets"."id"
"asset"
inner join "asset_job_status" on "asset_job_status"."assetId" = "asset"."id"
where
"assets"."deletedAt" is null
and "assets"."visibility" != $1
"asset"."deletedAt" is null
and "asset"."visibility" != $1
and (
"asset_job_status"."previewAt" is null
or "asset_job_status"."thumbnailAt" is null
or "assets"."thumbhash" is null
or "asset"."thumbhash" is null
)
-- AssetJobRepository.getForMigrationJob
select
"assets"."id",
"assets"."ownerId",
"assets"."encodedVideoPath",
"asset"."id",
"asset"."ownerId",
"asset"."encodedVideoPath",
(
select
coalesce(json_agg(agg), '[]')
from
(
select
"asset_files"."id",
"asset_files"."path",
"asset_files"."type"
"asset_file"."id",
"asset_file"."path",
"asset_file"."type"
from
"asset_files"
"asset_file"
where
"asset_files"."assetId" = "assets"."id"
"asset_file"."assetId" = "asset"."id"
) as agg
) as "files"
from
"assets"
"asset"
where
"assets"."id" = $1
"asset"."id" = $1
-- AssetJobRepository.getForGenerateThumbnailJob
select
"assets"."id",
"assets"."visibility",
"assets"."originalFileName",
"assets"."originalPath",
"assets"."ownerId",
"assets"."thumbhash",
"assets"."type",
"asset"."id",
"asset"."visibility",
"asset"."originalFileName",
"asset"."originalPath",
"asset"."ownerId",
"asset"."thumbhash",
"asset"."type",
(
select
coalesce(json_agg(agg), '[]')
from
(
select
"asset_files"."id",
"asset_files"."path",
"asset_files"."type"
"asset_file"."id",
"asset_file"."path",
"asset_file"."type"
from
"asset_files"
"asset_file"
where
"asset_files"."assetId" = "assets"."id"
"asset_file"."assetId" = "asset"."id"
) as agg
) as "files",
to_json("exif") as "exifInfo"
to_json("asset_exif") as "exifInfo"
from
"assets"
inner join "exif" on "assets"."id" = "exif"."assetId"
"asset"
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
where
"assets"."id" = $1
"asset"."id" = $1
-- AssetJobRepository.getForMetadataExtraction
select
"assets"."id",
"assets"."checksum",
"assets"."deviceAssetId",
"assets"."deviceId",
"assets"."fileCreatedAt",
"assets"."fileModifiedAt",
"assets"."isExternal",
"assets"."visibility",
"assets"."libraryId",
"assets"."livePhotoVideoId",
"assets"."localDateTime",
"assets"."originalFileName",
"assets"."originalPath",
"assets"."ownerId",
"assets"."sidecarPath",
"assets"."type",
"asset"."id",
"asset"."checksum",
"asset"."deviceAssetId",
"asset"."deviceId",
"asset"."fileCreatedAt",
"asset"."fileModifiedAt",
"asset"."isExternal",
"asset"."visibility",
"asset"."libraryId",
"asset"."livePhotoVideoId",
"asset"."localDateTime",
"asset"."originalFileName",
"asset"."originalPath",
"asset"."ownerId",
"asset"."sidecarPath",
"asset"."type",
(
select
coalesce(json_agg(agg), '[]')
from
(
select
"asset_faces".*
"asset_face".*
from
"asset_faces"
"asset_face"
where
"asset_faces"."assetId" = "assets"."id"
and "asset_faces"."deletedAt" is null
"asset_face"."assetId" = "asset"."id"
and "asset_face"."deletedAt" is null
) as agg
) as "faces"
from
"assets"
"asset"
where
"assets"."id" = $1
"asset"."id" = $1
-- AssetJobRepository.getAlbumThumbnailFiles
select
"asset_files"."id",
"asset_files"."path",
"asset_files"."type"
"asset_file"."id",
"asset_file"."path",
"asset_file"."type"
from
"asset_files"
"asset_file"
where
"asset_files"."assetId" = $1
and "asset_files"."type" = $2
"asset_file"."assetId" = $1
and "asset_file"."type" = $2
-- AssetJobRepository.streamForSearchDuplicates
select
"assets"."id"
"asset"."id"
from
"assets"
inner join "smart_search" on "assets"."id" = "smart_search"."assetId"
inner join "asset_job_status" as "job_status" on "job_status"."assetId" = "assets"."id"
"asset"
inner join "smart_search" on "asset"."id" = "smart_search"."assetId"
inner join "asset_job_status" as "job_status" on "job_status"."assetId" = "asset"."id"
where
"assets"."deletedAt" is null
and "assets"."visibility" in ('archive', 'timeline')
"asset"."deletedAt" is null
and "asset"."visibility" in ('archive', 'timeline')
and "job_status"."duplicatesDetectedAt" is null
-- AssetJobRepository.streamForEncodeClip
select
"assets"."id"
"asset"."id"
from
"assets"
inner join "asset_job_status" as "job_status" on "assetId" = "assets"."id"
"asset"
inner join "asset_job_status" as "job_status" on "assetId" = "asset"."id"
where
"assets"."visibility" != $1
and "assets"."deletedAt" is null
"asset"."visibility" != $1
and "asset"."deletedAt" is null
and "job_status"."previewAt" is not null
and not exists (
select
from
"smart_search"
where
"assetId" = "assets"."id"
"assetId" = "asset"."id"
)
-- AssetJobRepository.getForClipEncoding
select
"assets"."id",
"assets"."visibility",
"asset"."id",
"asset"."visibility",
(
select
coalesce(json_agg(agg), '[]')
from
(
select
"asset_files"."id",
"asset_files"."path",
"asset_files"."type"
"asset_file"."id",
"asset_file"."path",
"asset_file"."type"
from
"asset_files"
"asset_file"
where
"asset_files"."assetId" = "assets"."id"
and "asset_files"."type" = $1
"asset_file"."assetId" = "asset"."id"
and "asset_file"."type" = $1
) as agg
) as "files"
from
"assets"
"asset"
where
"assets"."id" = $2
"asset"."id" = $2
-- AssetJobRepository.getForDetectFacesJob
select
"assets"."id",
"assets"."visibility",
to_json("exif") as "exifInfo",
"asset"."id",
"asset"."visibility",
to_json("asset_exif") as "exifInfo",
(
select
coalesce(json_agg(agg), '[]')
from
(
select
"asset_faces".*
"asset_face".*
from
"asset_faces"
"asset_face"
where
"asset_faces"."assetId" = "assets"."id"
"asset_face"."assetId" = "asset"."id"
) as agg
) as "faces",
(
@@ -257,67 +257,67 @@ select
from
(
select
"asset_files"."id",
"asset_files"."path",
"asset_files"."type"
"asset_file"."id",
"asset_file"."path",
"asset_file"."type"
from
"asset_files"
"asset_file"
where
"asset_files"."assetId" = "assets"."id"
and "asset_files"."type" = $1
"asset_file"."assetId" = "asset"."id"
and "asset_file"."type" = $1
) as agg
) as "files"
from
"assets"
inner join "exif" on "assets"."id" = "exif"."assetId"
"asset"
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
where
"assets"."id" = $2
"asset"."id" = $2
-- AssetJobRepository.getForSyncAssets
select
"assets"."id",
"assets"."isOffline",
"assets"."libraryId",
"assets"."originalPath",
"assets"."status",
"assets"."fileModifiedAt"
"asset"."id",
"asset"."isOffline",
"asset"."libraryId",
"asset"."originalPath",
"asset"."status",
"asset"."fileModifiedAt"
from
"assets"
"asset"
where
"assets"."id" = any ($1::uuid[])
"asset"."id" = any ($1::uuid[])
-- AssetJobRepository.getForAssetDeletion
select
"assets"."id",
"assets"."visibility",
"assets"."libraryId",
"assets"."ownerId",
"assets"."livePhotoVideoId",
"assets"."sidecarPath",
"assets"."encodedVideoPath",
"assets"."originalPath",
to_json("exif") as "exifInfo",
"asset"."id",
"asset"."visibility",
"asset"."libraryId",
"asset"."ownerId",
"asset"."livePhotoVideoId",
"asset"."sidecarPath",
"asset"."encodedVideoPath",
"asset"."originalPath",
to_json("asset_exif") as "exifInfo",
(
select
coalesce(json_agg(agg), '[]')
from
(
select
"asset_faces".*,
"asset_face".*,
"person" as "person"
from
"asset_faces"
"asset_face"
left join lateral (
select
"person".*
from
"person"
where
"asset_faces"."personId" = "person"."id"
"asset_face"."personId" = "person"."id"
) as "person" on true
where
"asset_faces"."assetId" = "assets"."id"
and "asset_faces"."deletedAt" is null
"asset_face"."assetId" = "asset"."id"
and "asset_face"."deletedAt" is null
) as agg
) as "faces",
(
@@ -326,156 +326,156 @@ select
from
(
select
"asset_files"."id",
"asset_files"."path",
"asset_files"."type"
"asset_file"."id",
"asset_file"."path",
"asset_file"."type"
from
"asset_files"
"asset_file"
where
"asset_files"."assetId" = "assets"."id"
"asset_file"."assetId" = "asset"."id"
) as agg
) as "files",
to_json("stacked_assets") as "stack"
from
"assets"
left join "exif" on "assets"."id" = "exif"."assetId"
left join "asset_stack" on "asset_stack"."id" = "assets"."stackId"
"asset"
left join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
left join "stack" on "stack"."id" = "asset"."stackId"
left join lateral (
select
"asset_stack"."id",
"asset_stack"."primaryAssetId",
"stack"."id",
"stack"."primaryAssetId",
array_agg("stacked") as "assets"
from
"assets" as "stacked"
"asset" as "stacked"
where
"stacked"."deletedAt" is not null
and "stacked"."visibility" = $1
and "stacked"."stackId" = "asset_stack"."id"
and "stacked"."stackId" = "stack"."id"
group by
"asset_stack"."id"
) as "stacked_assets" on "asset_stack"."id" is not null
"stack"."id"
) as "stacked_assets" on "stack"."id" is not null
where
"assets"."id" = $2
"asset"."id" = $2
-- AssetJobRepository.streamForVideoConversion
select
"assets"."id"
"asset"."id"
from
"assets"
"asset"
where
"assets"."type" = $1
"asset"."type" = $1
and (
"assets"."encodedVideoPath" is null
or "assets"."encodedVideoPath" = $2
"asset"."encodedVideoPath" is null
or "asset"."encodedVideoPath" = $2
)
and "assets"."visibility" != $3
and "assets"."deletedAt" is null
and "asset"."visibility" != $3
and "asset"."deletedAt" is null
-- AssetJobRepository.getForVideoConversion
select
"assets"."id",
"assets"."ownerId",
"assets"."originalPath",
"assets"."encodedVideoPath"
"asset"."id",
"asset"."ownerId",
"asset"."originalPath",
"asset"."encodedVideoPath"
from
"assets"
"asset"
where
"assets"."id" = $1
and "assets"."type" = $2
"asset"."id" = $1
and "asset"."type" = $2
-- AssetJobRepository.streamForMetadataExtraction
select
"assets"."id"
"asset"."id"
from
"assets"
left join "asset_job_status" on "asset_job_status"."assetId" = "assets"."id"
"asset"
left join "asset_job_status" on "asset_job_status"."assetId" = "asset"."id"
where
(
"asset_job_status"."metadataExtractedAt" is null
or "asset_job_status"."assetId" is null
)
and "assets"."deletedAt" is null
and "asset"."deletedAt" is null
-- AssetJobRepository.getForStorageTemplateJob
select
"assets"."id",
"assets"."ownerId",
"assets"."type",
"assets"."checksum",
"assets"."originalPath",
"assets"."isExternal",
"assets"."sidecarPath",
"assets"."originalFileName",
"assets"."livePhotoVideoId",
"assets"."fileCreatedAt",
"exif"."timeZone",
"exif"."fileSizeInByte"
"asset"."id",
"asset"."ownerId",
"asset"."type",
"asset"."checksum",
"asset"."originalPath",
"asset"."isExternal",
"asset"."sidecarPath",
"asset"."originalFileName",
"asset"."livePhotoVideoId",
"asset"."fileCreatedAt",
"asset_exif"."timeZone",
"asset_exif"."fileSizeInByte"
from
"assets"
inner join "exif" on "assets"."id" = "exif"."assetId"
"asset"
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
where
"assets"."deletedAt" is null
and "assets"."id" = $1
"asset"."deletedAt" is null
and "asset"."id" = $1
-- AssetJobRepository.streamForStorageTemplateJob
select
"assets"."id",
"assets"."ownerId",
"assets"."type",
"assets"."checksum",
"assets"."originalPath",
"assets"."isExternal",
"assets"."sidecarPath",
"assets"."originalFileName",
"assets"."livePhotoVideoId",
"assets"."fileCreatedAt",
"exif"."timeZone",
"exif"."fileSizeInByte"
"asset"."id",
"asset"."ownerId",
"asset"."type",
"asset"."checksum",
"asset"."originalPath",
"asset"."isExternal",
"asset"."sidecarPath",
"asset"."originalFileName",
"asset"."livePhotoVideoId",
"asset"."fileCreatedAt",
"asset_exif"."timeZone",
"asset_exif"."fileSizeInByte"
from
"assets"
inner join "exif" on "assets"."id" = "exif"."assetId"
"asset"
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
where
"assets"."deletedAt" is null
"asset"."deletedAt" is null
-- AssetJobRepository.streamForDeletedJob
select
"id",
"isOffline"
from
"assets"
"asset"
where
"assets"."deletedAt" <= $1
"asset"."deletedAt" <= $1
-- AssetJobRepository.streamForSidecar
select
"assets"."id"
"asset"."id"
from
"assets"
"asset"
where
(
"assets"."sidecarPath" = $1
or "assets"."sidecarPath" is null
"asset"."sidecarPath" = $1
or "asset"."sidecarPath" is null
)
and "assets"."visibility" != $2
and "asset"."visibility" != $2
-- AssetJobRepository.streamForDetectFacesJob
select
"assets"."id"
"asset"."id"
from
"assets"
inner join "asset_job_status" as "job_status" on "assetId" = "assets"."id"
"asset"
inner join "asset_job_status" as "job_status" on "assetId" = "asset"."id"
where
"assets"."visibility" != $1
and "assets"."deletedAt" is null
"asset"."visibility" != $1
and "asset"."deletedAt" is null
and "job_status"."previewAt" is not null
and "job_status"."facesRecognizedAt" is null
order by
"assets"."createdAt" desc
"asset"."createdAt" desc
-- AssetJobRepository.streamForMigrationJob
select
"id"
from
"assets"
"asset"
where
"assets"."deletedAt" is null
"asset"."deletedAt" is null

View File

@@ -1,7 +1,7 @@
-- NOTE: This file is auto generated by ./sql-generator
-- AssetRepository.updateAllExif
update "exif"
update "asset_exif"
set
"model" = $1
where
@@ -23,42 +23,42 @@ with
min(("localDateTime" at time zone 'UTC')::date)
)::int
from
assets
asset
),
date_part('year', current_date)::int - 1
) as "year"
)
select
"a".*,
to_json("exif") as "exifInfo"
to_json("asset_exif") as "exifInfo"
from
"today"
inner join lateral (
select
"assets".*
"asset".*
from
"assets"
inner join "asset_job_status" on "assets"."id" = "asset_job_status"."assetId"
"asset"
inner join "asset_job_status" on "asset"."id" = "asset_job_status"."assetId"
where
"asset_job_status"."previewAt" is not null
and (assets."localDateTime" at time zone 'UTC')::date = today.date
and "assets"."ownerId" = any ($3::uuid[])
and "assets"."visibility" = $4
and (asset."localDateTime" at time zone 'UTC')::date = today.date
and "asset"."ownerId" = any ($3::uuid[])
and "asset"."visibility" = $4
and exists (
select
from
"asset_files"
"asset_file"
where
"assetId" = "assets"."id"
and "asset_files"."type" = $5
"assetId" = "asset"."id"
and "asset_file"."type" = $5
)
and "assets"."deletedAt" is null
and "asset"."deletedAt" is null
order by
(assets."localDateTime" at time zone 'UTC')::date desc
(asset."localDateTime" at time zone 'UTC')::date desc
limit
$6
) as "a" on true
inner join "exif" on "a"."id" = "exif"."assetId"
inner join "asset_exif" on "a"."id" = "asset_exif"."assetId"
)
select
date_part(
@@ -75,36 +75,36 @@ order by
-- AssetRepository.getByIds
select
"assets".*
"asset".*
from
"assets"
"asset"
where
"assets"."id" = any ($1::uuid[])
"asset"."id" = any ($1::uuid[])
-- AssetRepository.getByIdsWithAllRelationsButStacks
select
"assets".*,
"asset".*,
(
select
coalesce(json_agg(agg), '[]')
from
(
select
"asset_faces".*,
"asset_face".*,
"person" as "person"
from
"asset_faces"
"asset_face"
left join lateral (
select
"person".*
from
"person"
where
"asset_faces"."personId" = "person"."id"
"asset_face"."personId" = "person"."id"
) as "person" on true
where
"asset_faces"."assetId" = "assets"."id"
and "asset_faces"."deletedAt" is null
"asset_face"."assetId" = "asset"."id"
and "asset_face"."deletedAt" is null
) as agg
) as "faces",
(
@@ -113,36 +113,36 @@ select
from
(
select
"tags"."id",
"tags"."value",
"tags"."createdAt",
"tags"."updatedAt",
"tags"."color",
"tags"."parentId"
"tag"."id",
"tag"."value",
"tag"."createdAt",
"tag"."updatedAt",
"tag"."color",
"tag"."parentId"
from
"tags"
inner join "tag_asset" on "tags"."id" = "tag_asset"."tagsId"
"tag"
inner join "tag_asset" on "tag"."id" = "tag_asset"."tagsId"
where
"assets"."id" = "tag_asset"."assetsId"
"asset"."id" = "tag_asset"."assetsId"
) as agg
) as "tags",
to_json("exif") as "exifInfo"
to_json("asset_exif") as "exifInfo"
from
"assets"
left join "exif" on "assets"."id" = "exif"."assetId"
"asset"
left join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
where
"assets"."id" = any ($1::uuid[])
"asset"."id" = any ($1::uuid[])
-- AssetRepository.deleteAll
delete from "assets"
delete from "asset"
where
"ownerId" = $1
-- AssetRepository.getByLibraryIdAndOriginalPath
select
"assets".*
"asset".*
from
"assets"
"asset"
where
"libraryId" = $1::uuid
and "originalPath" = $2
@@ -153,7 +153,7 @@ limit
select
"deviceAssetId"
from
"assets"
"asset"
where
"ownerId" = $1::uuid
and "deviceId" = $2
@@ -164,22 +164,22 @@ where
select
count(*) as "count"
from
"assets"
"asset"
where
"livePhotoVideoId" = $1::uuid
-- AssetRepository.getById
select
"assets".*
"asset".*
from
"assets"
"asset"
where
"assets"."id" = $1::uuid
"asset"."id" = $1::uuid
limit
$2
-- AssetRepository.updateAll
update "assets"
update "asset"
set
"deviceId" = $1
where
@@ -187,9 +187,9 @@ where
-- AssetRepository.getByChecksum
select
"assets".*
"asset".*
from
"assets"
"asset"
where
"ownerId" = $1::uuid
and "checksum" = $2
@@ -203,7 +203,7 @@ select
"checksum",
"deletedAt"
from
"assets"
"asset"
where
"ownerId" = $1::uuid
and "checksum" in ($2)
@@ -212,7 +212,7 @@ where
select
"id"
from
"assets"
"asset"
where
"ownerId" = $1::uuid
and "checksum" = $2
@@ -222,20 +222,20 @@ limit
-- AssetRepository.getTimeBuckets
with
"assets" as (
"asset" as (
select
date_trunc('MONTH', "localDateTime" AT TIME ZONE 'UTC') AT TIME ZONE 'UTC' as "timeBucket"
from
"assets"
"asset"
where
"assets"."deletedAt" is null
and "assets"."visibility" in ('archive', 'timeline')
"asset"."deletedAt" is null
and "asset"."visibility" in ('archive', 'timeline')
)
select
("timeBucket" AT TIME ZONE 'UTC')::date::text as "timeBucket",
count(*) as "count"
from
"assets"
"asset"
group by
"timeBucket"
order by
@@ -245,37 +245,37 @@ order by
with
"cte" as (
select
"assets"."duration",
"assets"."id",
"assets"."visibility",
"assets"."isFavorite",
assets.type = 'IMAGE' as "isImage",
assets."deletedAt" is not null as "isTrashed",
"assets"."livePhotoVideoId",
"asset"."duration",
"asset"."id",
"asset"."visibility",
"asset"."isFavorite",
asset.type = 'IMAGE' as "isImage",
asset."deletedAt" is not null as "isTrashed",
"asset"."livePhotoVideoId",
extract(
epoch
from
(
assets."localDateTime" - assets."fileCreatedAt" at time zone 'UTC'
asset."localDateTime" - asset."fileCreatedAt" at time zone 'UTC'
)
)::real / 3600 as "localOffsetHours",
"assets"."ownerId",
"assets"."status",
assets."fileCreatedAt" at time zone 'utc' as "fileCreatedAt",
encode("assets"."thumbhash", 'base64') as "thumbhash",
"exif"."city",
"exif"."country",
"exif"."projectionType",
"asset"."ownerId",
"asset"."status",
asset."fileCreatedAt" at time zone 'utc' as "fileCreatedAt",
encode("asset"."thumbhash", 'base64') as "thumbhash",
"asset_exif"."city",
"asset_exif"."country",
"asset_exif"."projectionType",
coalesce(
case
when exif."exifImageHeight" = 0
or exif."exifImageWidth" = 0 then 1
when "exif"."orientation" in ('5', '6', '7', '8', '-90', '90') then round(
exif."exifImageHeight"::numeric / exif."exifImageWidth"::numeric,
when asset_exif."exifImageHeight" = 0
or asset_exif."exifImageWidth" = 0 then 1
when "asset_exif"."orientation" in ('5', '6', '7', '8', '-90', '90') then round(
asset_exif."exifImageHeight"::numeric / asset_exif."exifImageWidth"::numeric,
3
)
else round(
exif."exifImageWidth"::numeric / exif."exifImageHeight"::numeric,
asset_exif."exifImageWidth"::numeric / asset_exif."exifImageHeight"::numeric,
3
)
end,
@@ -283,34 +283,34 @@ with
) as "ratio",
"stack"
from
"assets"
inner join "exif" on "assets"."id" = "exif"."assetId"
"asset"
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
left join lateral (
select
array[stacked."stackId"::text, count('stacked')::text] as "stack"
from
"assets" as "stacked"
"asset" as "stacked"
where
"stacked"."stackId" = "assets"."stackId"
"stacked"."stackId" = "asset"."stackId"
and "stacked"."deletedAt" is null
and "stacked"."visibility" = $1
group by
"stacked"."stackId"
) as "stacked_assets" on true
where
"assets"."deletedAt" is null
and "assets"."visibility" in ('archive', 'timeline')
"asset"."deletedAt" is null
and "asset"."visibility" in ('archive', 'timeline')
and date_trunc('MONTH', "localDateTime" AT TIME ZONE 'UTC') AT TIME ZONE 'UTC' = $2
and not exists (
select
from
"asset_stack"
"stack"
where
"asset_stack"."id" = "assets"."stackId"
and "asset_stack"."primaryAssetId" != "assets"."id"
"stack"."id" = "asset"."stackId"
and "stack"."primaryAssetId" != "asset"."id"
)
order by
"assets"."fileCreatedAt" desc
"asset"."fileCreatedAt" desc
),
"agg" as (
select
@@ -345,7 +345,7 @@ with
select
"city"
from
"exif"
"asset_exif"
where
"city" is not null
group by
@@ -354,12 +354,12 @@ with
count("assetId") >= $1
)
select distinct
on ("exif"."city") "assetId" as "data",
"exif"."city" as "value"
on ("asset_exif"."city") "assetId" as "data",
"asset_exif"."city" as "value"
from
"assets"
inner join "exif" on "assets"."id" = "exif"."assetId"
inner join "cities" on "exif"."city" = "cities"."city"
"asset"
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
inner join "cities" on "asset_exif"."city" = "cities"."city"
where
"ownerId" = $2::uuid
and "visibility" = $3
@@ -370,63 +370,63 @@ limit
-- AssetRepository.getAllForUserFullSync
select
"assets".*,
to_json("exif") as "exifInfo",
"asset".*,
to_json("asset_exif") as "exifInfo",
to_json("stacked_assets") as "stack"
from
"assets"
left join "exif" on "assets"."id" = "exif"."assetId"
left join "asset_stack" on "asset_stack"."id" = "assets"."stackId"
"asset"
left join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
left join "stack" on "stack"."id" = "asset"."stackId"
left join lateral (
select
"asset_stack".*,
"stack".*,
count("stacked") as "assetCount"
from
"assets" as "stacked"
"asset" as "stacked"
where
"stacked"."stackId" = "asset_stack"."id"
"stacked"."stackId" = "stack"."id"
group by
"asset_stack"."id"
) as "stacked_assets" on "asset_stack"."id" is not null
"stack"."id"
) as "stacked_assets" on "stack"."id" is not null
where
"assets"."ownerId" = $1::uuid
and "assets"."visibility" != $2
and "assets"."updatedAt" <= $3
and "assets"."id" > $4
"asset"."ownerId" = $1::uuid
and "asset"."visibility" != $2
and "asset"."updatedAt" <= $3
and "asset"."id" > $4
order by
"assets"."id"
"asset"."id"
limit
$5
-- AssetRepository.getChangedDeltaSync
select
"assets".*,
to_json("exif") as "exifInfo",
"asset".*,
to_json("asset_exif") as "exifInfo",
to_json("stacked_assets") as "stack"
from
"assets"
left join "exif" on "assets"."id" = "exif"."assetId"
left join "asset_stack" on "asset_stack"."id" = "assets"."stackId"
"asset"
left join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
left join "stack" on "stack"."id" = "asset"."stackId"
left join lateral (
select
"asset_stack".*,
"stack".*,
count("stacked") as "assetCount"
from
"assets" as "stacked"
"asset" as "stacked"
where
"stacked"."stackId" = "asset_stack"."id"
"stacked"."stackId" = "stack"."id"
group by
"asset_stack"."id"
) as "stacked_assets" on "asset_stack"."id" is not null
"stack"."id"
) as "stacked_assets" on "stack"."id" is not null
where
"assets"."ownerId" = any ($1::uuid[])
and "assets"."visibility" != $2
and "assets"."updatedAt" > $3
"asset"."ownerId" = any ($1::uuid[])
and "asset"."visibility" != $2
and "asset"."updatedAt" > $3
limit
$4
-- AssetRepository.detectOfflineExternalAssets
update "assets"
update "asset"
set
"isOffline" = $1,
"deletedAt" = $2
@@ -449,9 +449,9 @@ where
select
"originalPath"
from
"assets"
"asset"
where
"assets"."originalPath" = "path"
"asset"."originalPath" = "path"
and "libraryId" = $2::uuid
and "isExternal" = $3
)

View File

@@ -4,31 +4,31 @@
with
"duplicates" as (
select
"assets"."duplicateId",
"asset"."duplicateId",
json_agg(
"asset"
"asset2"
order by
"assets"."localDateTime" asc
"asset"."localDateTime" asc
) as "assets"
from
"assets"
"asset"
left join lateral (
select
"assets".*,
"exif" as "exifInfo"
"asset".*,
"asset_exif" as "exifInfo"
from
"exif"
"asset_exif"
where
"exif"."assetId" = "assets"."id"
) as "asset" on true
"asset_exif"."assetId" = "asset"."id"
) as "asset2" on true
where
"assets"."visibility" in ('archive', 'timeline')
and "assets"."ownerId" = $1::uuid
and "assets"."duplicateId" is not null
and "assets"."deletedAt" is null
and "assets"."stackId" is null
"asset"."visibility" in ('archive', 'timeline')
and "asset"."ownerId" = $1::uuid
and "asset"."duplicateId" is not null
and "asset"."deletedAt" is null
and "asset"."stackId" is null
group by
"assets"."duplicateId"
"asset"."duplicateId"
),
"unique" as (
select
@@ -39,13 +39,13 @@ with
json_array_length("assets") = $2
),
"removed_unique" as (
update "assets"
update "asset"
set
"duplicateId" = $3
from
"unique"
where
"assets"."duplicateId" = "unique"."duplicateId"
"asset"."duplicateId" = "unique"."duplicateId"
)
select
*
@@ -61,7 +61,7 @@ where
)
-- DuplicateRepository.delete
update "assets"
update "asset"
set
"duplicateId" = $1
where
@@ -69,7 +69,7 @@ where
and "duplicateId" = $3
-- DuplicateRepository.deleteAll
update "assets"
update "asset"
set
"duplicateId" = $1
where
@@ -83,19 +83,19 @@ set
with
"cte" as (
select
"assets"."id" as "assetId",
"assets"."duplicateId",
"asset"."id" as "assetId",
"asset"."duplicateId",
smart_search.embedding <=> $1 as "distance"
from
"assets"
inner join "smart_search" on "assets"."id" = "smart_search"."assetId"
"asset"
inner join "smart_search" on "asset"."id" = "smart_search"."assetId"
where
"assets"."visibility" in ('archive', 'timeline')
and "assets"."ownerId" = any ($2::uuid[])
and "assets"."deletedAt" is null
and "assets"."type" = $3
and "assets"."id" != $4::uuid
and "assets"."stackId" is null
"asset"."visibility" in ('archive', 'timeline')
and "asset"."ownerId" = any ($2::uuid[])
and "asset"."deletedAt" is null
and "asset"."type" = $3
and "asset"."id" != $4::uuid
and "asset"."stackId" is null
order by
"distance"
limit
@@ -110,7 +110,7 @@ where
commit
-- DuplicateRepository.merge
update "assets"
update "asset"
set
where
(

View File

@@ -2,30 +2,30 @@
-- LibraryRepository.get
select
"libraries".*
"library".*
from
"libraries"
"library"
where
"libraries"."id" = $1
and "libraries"."deletedAt" is null
"library"."id" = $1
and "library"."deletedAt" is null
-- LibraryRepository.getAll
select
"libraries".*
"library".*
from
"libraries"
"library"
where
"libraries"."deletedAt" is null
"library"."deletedAt" is null
order by
"createdAt" asc
-- LibraryRepository.getAllDeleted
select
"libraries".*
"library".*
from
"libraries"
"library"
where
"libraries"."deletedAt" is not null
"library"."deletedAt" is not null
order by
"createdAt" asc
@@ -34,32 +34,32 @@ select
count(*) filter (
where
(
"assets"."type" = $1
and "assets"."visibility" != $2
"asset"."type" = $1
and "asset"."visibility" != $2
)
) as "photos",
count(*) filter (
where
(
"assets"."type" = $3
and "assets"."visibility" != $4
"asset"."type" = $3
and "asset"."visibility" != $4
)
) as "videos",
coalesce(sum("exif"."fileSizeInByte"), $5) as "usage"
coalesce(sum("asset_exif"."fileSizeInByte"), $5) as "usage"
from
"libraries"
inner join "assets" on "assets"."libraryId" = "libraries"."id"
left join "exif" on "exif"."assetId" = "assets"."id"
"library"
inner join "asset" on "asset"."libraryId" = "library"."id"
left join "asset_exif" on "asset_exif"."assetId" = "asset"."id"
where
"libraries"."id" = $6
"library"."id" = $6
group by
"libraries"."id"
"library"."id"
select
0::int as "photos",
0::int as "videos",
0::int as "usage",
0::int as "total"
from
"libraries"
"library"
where
"libraries"."id" = $1
"library"."id" = $1

View File

@@ -3,28 +3,28 @@
-- MapRepository.getMapMarkers
select
"id",
"exif"."latitude" as "lat",
"exif"."longitude" as "lon",
"exif"."city",
"exif"."state",
"exif"."country"
"asset_exif"."latitude" as "lat",
"asset_exif"."longitude" as "lon",
"asset_exif"."city",
"asset_exif"."state",
"asset_exif"."country"
from
"assets"
inner join "exif" on "assets"."id" = "exif"."assetId"
and "exif"."latitude" is not null
and "exif"."longitude" is not null
"asset"
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
and "asset_exif"."latitude" is not null
and "asset_exif"."longitude" is not null
where
"assets"."visibility" = $1
"asset"."visibility" = $1
and "deletedAt" is null
and (
"ownerId" in ($2)
or exists (
select
from
"albums_assets_assets"
"album_asset"
where
"assets"."id" = "albums_assets_assets"."assetsId"
and "albums_assets_assets"."albumsId" in ($3)
"asset"."id" = "album_asset"."assetsId"
and "album_asset"."albumsId" in ($3)
)
)
order by

View File

@@ -4,7 +4,7 @@
select
count(*) as "total"
from
"memories"
"memory"
where
"deletedAt" is null
and "ownerId" = $1
@@ -13,7 +13,7 @@ where
select
count(*) as "total"
from
"memories"
"memory"
where
(
"showAt" is null
@@ -34,21 +34,21 @@ select
from
(
select
"assets".*
"asset".*
from
"assets"
inner join "memories_assets_assets" on "assets"."id" = "memories_assets_assets"."assetsId"
"asset"
inner join "memory_asset" on "asset"."id" = "memory_asset"."assetsId"
where
"memories_assets_assets"."memoriesId" = "memories"."id"
and "assets"."visibility" = 'timeline'
and "assets"."deletedAt" is null
"memory_asset"."memoriesId" = "memory"."id"
and "asset"."visibility" = 'timeline'
and "asset"."deletedAt" is null
order by
"assets"."fileCreatedAt" asc
"asset"."fileCreatedAt" asc
) as agg
) as "assets",
"memories".*
"memory".*
from
"memories"
"memory"
where
"deletedAt" is null
and "ownerId" = $1
@@ -63,21 +63,21 @@ select
from
(
select
"assets".*
"asset".*
from
"assets"
inner join "memories_assets_assets" on "assets"."id" = "memories_assets_assets"."assetsId"
"asset"
inner join "memory_asset" on "asset"."id" = "memory_asset"."assetsId"
where
"memories_assets_assets"."memoriesId" = "memories"."id"
and "assets"."visibility" = 'timeline'
and "assets"."deletedAt" is null
"memory_asset"."memoriesId" = "memory"."id"
and "asset"."visibility" = 'timeline'
and "asset"."deletedAt" is null
order by
"assets"."fileCreatedAt" asc
"asset"."fileCreatedAt" asc
) as agg
) as "assets",
"memories".*
"memory".*
from
"memories"
"memory"
where
(
"showAt" is null
@@ -94,66 +94,66 @@ order by
-- MemoryRepository.get
select
"memories".*,
"memory".*,
(
select
coalesce(json_agg(agg), '[]')
from
(
select
"assets".*
"asset".*
from
"assets"
inner join "memories_assets_assets" on "assets"."id" = "memories_assets_assets"."assetsId"
"asset"
inner join "memory_asset" on "asset"."id" = "memory_asset"."assetsId"
where
"memories_assets_assets"."memoriesId" = "memories"."id"
and "assets"."visibility" = 'timeline'
and "assets"."deletedAt" is null
"memory_asset"."memoriesId" = "memory"."id"
and "asset"."visibility" = 'timeline'
and "asset"."deletedAt" is null
order by
"assets"."fileCreatedAt" asc
"asset"."fileCreatedAt" asc
) as agg
) as "assets"
from
"memories"
"memory"
where
"id" = $1
and "deletedAt" is null
-- MemoryRepository.update
update "memories"
update "memory"
set
"ownerId" = $1,
"isSaved" = $2
where
"id" = $3
select
"memories".*,
"memory".*,
(
select
coalesce(json_agg(agg), '[]')
from
(
select
"assets".*
"asset".*
from
"assets"
inner join "memories_assets_assets" on "assets"."id" = "memories_assets_assets"."assetsId"
"asset"
inner join "memory_asset" on "asset"."id" = "memory_asset"."assetsId"
where
"memories_assets_assets"."memoriesId" = "memories"."id"
and "assets"."visibility" = 'timeline'
and "assets"."deletedAt" is null
"memory_asset"."memoriesId" = "memory"."id"
and "asset"."visibility" = 'timeline'
and "asset"."deletedAt" is null
order by
"assets"."fileCreatedAt" asc
"asset"."fileCreatedAt" asc
) as agg
) as "assets"
from
"memories"
"memory"
where
"id" = $1
and "deletedAt" is null
-- MemoryRepository.delete
delete from "memories"
delete from "memory"
where
"id" = $1
@@ -161,13 +161,13 @@ where
select
"assetsId"
from
"memories_assets_assets"
"memory_asset"
where
"memoriesId" = $1
and "assetsId" in ($2)
-- MemoryRepository.addAssetIds
insert into
"memories_assets_assets" ("memoriesId", "assetsId")
"memory_asset" ("memoriesId", "assetsId")
values
($1, $2)

View File

@@ -11,7 +11,7 @@ select
"data",
"readAt"
from
"notifications"
"notification"
where
"userId" = $1
and "deletedAt" is null
@@ -29,7 +29,7 @@ select
"data",
"readAt"
from
"notifications"
"notification"
where
(
"userId" = $1

View File

@@ -2,7 +2,7 @@
-- PartnerRepository.getAll
select
"partners".*,
"partner".*,
(
select
to_json(obj)
@@ -16,9 +16,9 @@ select
"profileImagePath",
"profileChangedAt"
from
"users" as "sharedBy"
"user" as "sharedBy"
where
"sharedBy"."id" = "partners"."sharedById"
"sharedBy"."id" = "partner"."sharedById"
) as obj
) as "sharedBy",
(
@@ -34,16 +34,16 @@ select
"profileImagePath",
"profileChangedAt"
from
"users" as "sharedWith"
"user" as "sharedWith"
where
"sharedWith"."id" = "partners"."sharedWithId"
"sharedWith"."id" = "partner"."sharedWithId"
) as obj
) as "sharedWith"
from
"partners"
inner join "users" as "sharedBy" on "partners"."sharedById" = "sharedBy"."id"
"partner"
inner join "user" as "sharedBy" on "partner"."sharedById" = "sharedBy"."id"
and "sharedBy"."deletedAt" is null
inner join "users" as "sharedWith" on "partners"."sharedWithId" = "sharedWith"."id"
inner join "user" as "sharedWith" on "partner"."sharedWithId" = "sharedWith"."id"
and "sharedWith"."deletedAt" is null
where
(
@@ -53,7 +53,7 @@ where
-- PartnerRepository.get
select
"partners".*,
"partner".*,
(
select
to_json(obj)
@@ -67,9 +67,9 @@ select
"profileImagePath",
"profileChangedAt"
from
"users" as "sharedBy"
"user" as "sharedBy"
where
"sharedBy"."id" = "partners"."sharedById"
"sharedBy"."id" = "partner"."sharedById"
) as obj
) as "sharedBy",
(
@@ -85,23 +85,23 @@ select
"profileImagePath",
"profileChangedAt"
from
"users" as "sharedWith"
"user" as "sharedWith"
where
"sharedWith"."id" = "partners"."sharedWithId"
"sharedWith"."id" = "partner"."sharedWithId"
) as obj
) as "sharedWith"
from
"partners"
inner join "users" as "sharedBy" on "partners"."sharedById" = "sharedBy"."id"
"partner"
inner join "user" as "sharedBy" on "partner"."sharedById" = "sharedBy"."id"
and "sharedBy"."deletedAt" is null
inner join "users" as "sharedWith" on "partners"."sharedWithId" = "sharedWith"."id"
inner join "user" as "sharedWith" on "partner"."sharedWithId" = "sharedWith"."id"
and "sharedWith"."deletedAt" is null
where
"sharedWithId" = $1
and "sharedById" = $2
-- PartnerRepository.update
update "partners"
update "partner"
set
"inTimeline" = $1
where
@@ -122,9 +122,9 @@ returning
"profileImagePath",
"profileChangedAt"
from
"users" as "sharedBy"
"user" as "sharedBy"
where
"sharedBy"."id" = "partners"."sharedById"
"sharedBy"."id" = "partner"."sharedById"
) as obj
) as "sharedBy",
(
@@ -140,14 +140,14 @@ returning
"profileImagePath",
"profileChangedAt"
from
"users" as "sharedWith"
"user" as "sharedWith"
where
"sharedWith"."id" = "partners"."sharedWithId"
"sharedWith"."id" = "partner"."sharedWithId"
) as obj
) as "sharedWith"
-- PartnerRepository.remove
delete from "partners"
delete from "partner"
where
"sharedWithId" = $1
and "sharedById" = $2

View File

@@ -1,11 +1,11 @@
-- NOTE: This file is auto generated by ./sql-generator
-- PersonRepository.reassignFaces
update "asset_faces"
update "asset_face"
set
"personId" = $1
where
"asset_faces"."personId" = $2
"asset_face"."personId" = $2
-- PersonRepository.delete
delete from "person"
@@ -17,26 +17,26 @@ select
"person".*
from
"person"
inner join "asset_faces" on "asset_faces"."personId" = "person"."id"
inner join "assets" on "asset_faces"."assetId" = "assets"."id"
and "assets"."visibility" = 'timeline'
and "assets"."deletedAt" is null
inner join "asset_face" on "asset_face"."personId" = "person"."id"
inner join "asset" on "asset_face"."assetId" = "asset"."id"
and "asset"."visibility" = 'timeline'
and "asset"."deletedAt" is null
where
"person"."ownerId" = $1
and "asset_faces"."deletedAt" is null
and "asset_face"."deletedAt" is null
and "person"."isHidden" = $2
group by
"person"."id"
having
(
"person"."name" != $3
or count("asset_faces"."assetId") >= $4
or count("asset_face"."assetId") >= $4
)
order by
"person"."isHidden" asc,
"person"."isFavorite" desc,
NULLIF(person.name, '') is null asc,
count("asset_faces"."assetId") desc,
count("asset_face"."assetId") desc,
NULLIF(person.name, '') asc nulls last,
"person"."createdAt"
limit
@@ -49,17 +49,17 @@ select
"person".*
from
"person"
left join "asset_faces" on "asset_faces"."personId" = "person"."id"
left join "asset_face" on "asset_face"."personId" = "person"."id"
where
"asset_faces"."deletedAt" is null
"asset_face"."deletedAt" is null
group by
"person"."id"
having
count("asset_faces"."assetId") = $1
count("asset_face"."assetId") = $1
-- PersonRepository.getFaces
select
"asset_faces".*,
"asset_face".*,
(
select
to_json(obj)
@@ -70,20 +70,20 @@ select
from
"person"
where
"person"."id" = "asset_faces"."personId"
"person"."id" = "asset_face"."personId"
) as obj
) as "person"
from
"asset_faces"
"asset_face"
where
"asset_faces"."assetId" = $1
and "asset_faces"."deletedAt" is null
"asset_face"."assetId" = $1
and "asset_face"."deletedAt" is null
order by
"asset_faces"."boundingBoxX1" asc
"asset_face"."boundingBoxX1" asc
-- PersonRepository.getFaceById
select
"asset_faces".*,
"asset_face".*,
(
select
to_json(obj)
@@ -94,33 +94,33 @@ select
from
"person"
where
"person"."id" = "asset_faces"."personId"
"person"."id" = "asset_face"."personId"
) as obj
) as "person"
from
"asset_faces"
"asset_face"
where
"asset_faces"."id" = $1
and "asset_faces"."deletedAt" is null
"asset_face"."id" = $1
and "asset_face"."deletedAt" is null
-- PersonRepository.getFaceForFacialRecognitionJob
select
"asset_faces"."id",
"asset_faces"."personId",
"asset_faces"."sourceType",
"asset_face"."id",
"asset_face"."personId",
"asset_face"."sourceType",
(
select
to_json(obj)
from
(
select
"assets"."ownerId",
"assets"."visibility",
"assets"."fileCreatedAt"
"asset"."ownerId",
"asset"."visibility",
"asset"."fileCreatedAt"
from
"assets"
"asset"
where
"assets"."id" = "asset_faces"."assetId"
"asset"."id" = "asset_face"."assetId"
) as obj
) as "asset",
(
@@ -133,51 +133,51 @@ select
from
"face_search"
where
"face_search"."faceId" = "asset_faces"."id"
"face_search"."faceId" = "asset_face"."id"
) as obj
) as "faceSearch"
from
"asset_faces"
"asset_face"
where
"asset_faces"."id" = $1
and "asset_faces"."deletedAt" is null
"asset_face"."id" = $1
and "asset_face"."deletedAt" is null
-- PersonRepository.getDataForThumbnailGenerationJob
select
"person"."ownerId",
"asset_faces"."boundingBoxX1" as "x1",
"asset_faces"."boundingBoxY1" as "y1",
"asset_faces"."boundingBoxX2" as "x2",
"asset_faces"."boundingBoxY2" as "y2",
"asset_faces"."imageWidth" as "oldWidth",
"asset_faces"."imageHeight" as "oldHeight",
"assets"."type",
"assets"."originalPath",
"exif"."orientation" as "exifOrientation",
"asset_face"."boundingBoxX1" as "x1",
"asset_face"."boundingBoxY1" as "y1",
"asset_face"."boundingBoxX2" as "x2",
"asset_face"."boundingBoxY2" as "y2",
"asset_face"."imageWidth" as "oldWidth",
"asset_face"."imageHeight" as "oldHeight",
"asset"."type",
"asset"."originalPath",
"asset_exif"."orientation" as "exifOrientation",
(
select
"asset_files"."path"
"asset_file"."path"
from
"asset_files"
"asset_file"
where
"asset_files"."assetId" = "assets"."id"
and "asset_files"."type" = 'preview'
"asset_file"."assetId" = "asset"."id"
and "asset_file"."type" = 'preview'
) as "previewPath"
from
"person"
inner join "asset_faces" on "asset_faces"."id" = "person"."faceAssetId"
inner join "assets" on "asset_faces"."assetId" = "assets"."id"
left join "exif" on "exif"."assetId" = "assets"."id"
inner join "asset_face" on "asset_face"."id" = "person"."faceAssetId"
inner join "asset" on "asset_face"."assetId" = "asset"."id"
left join "asset_exif" on "asset_exif"."assetId" = "asset"."id"
where
"person"."id" = $1
and "asset_faces"."deletedAt" is null
and "asset_face"."deletedAt" is null
-- PersonRepository.reassignFace
update "asset_faces"
update "asset_face"
set
"personId" = $1
where
"asset_faces"."id" = $2
"asset_face"."id" = $2
-- PersonRepository.getByName
select
@@ -209,15 +209,15 @@ where
-- PersonRepository.getStatistics
select
count(distinct ("assets"."id")) as "count"
count(distinct ("asset"."id")) as "count"
from
"asset_faces"
left join "assets" on "assets"."id" = "asset_faces"."assetId"
and "asset_faces"."personId" = $1
and "assets"."visibility" = 'timeline'
and "assets"."deletedAt" is null
"asset_face"
left join "asset" on "asset"."id" = "asset_face"."assetId"
and "asset_face"."personId" = $1
and "asset"."visibility" = 'timeline'
and "asset"."deletedAt" is null
where
"asset_faces"."deletedAt" is null
"asset_face"."deletedAt" is null
-- PersonRepository.getNumberOfPeople
select
@@ -235,18 +235,18 @@ where
exists (
select
from
"asset_faces"
"asset_face"
where
"asset_faces"."personId" = "person"."id"
and "asset_faces"."deletedAt" is null
"asset_face"."personId" = "person"."id"
and "asset_face"."deletedAt" is null
and exists (
select
from
"assets"
"asset"
where
"assets"."id" = "asset_faces"."assetId"
and "assets"."visibility" = 'timeline'
and "assets"."deletedAt" is null
"asset"."id" = "asset_face"."assetId"
and "asset"."visibility" = 'timeline'
and "asset"."deletedAt" is null
)
)
and "person"."ownerId" = $2
@@ -268,18 +268,18 @@ from
-- PersonRepository.getFacesByIds
select
"asset_faces".*,
"asset_face".*,
(
select
to_json(obj)
from
(
select
"assets".*
"asset".*
from
"assets"
"asset"
where
"assets"."id" = "asset_faces"."assetId"
"asset"."id" = "asset_face"."assetId"
) as obj
) as "asset",
(
@@ -292,24 +292,24 @@ select
from
"person"
where
"person"."id" = "asset_faces"."personId"
"person"."id" = "asset_face"."personId"
) as obj
) as "person"
from
"asset_faces"
"asset_face"
where
"asset_faces"."assetId" in ($1)
and "asset_faces"."personId" in ($2)
and "asset_faces"."deletedAt" is null
"asset_face"."assetId" in ($1)
and "asset_face"."personId" in ($2)
and "asset_face"."deletedAt" is null
-- PersonRepository.getRandomFace
select
"asset_faces".*
"asset_face".*
from
"asset_faces"
"asset_face"
where
"asset_faces"."personId" = $1
and "asset_faces"."deletedAt" is null
"asset_face"."personId" = $1
and "asset_face"."deletedAt" is null
-- PersonRepository.getLatestFaceDate
select
@@ -318,16 +318,16 @@ from
"asset_job_status"
-- PersonRepository.deleteAssetFace
delete from "asset_faces"
delete from "asset_face"
where
"asset_faces"."id" = $1
"asset_face"."id" = $1
-- PersonRepository.softDeleteAssetFaces
update "asset_faces"
update "asset_face"
set
"deletedAt" = $1
where
"asset_faces"."id" = $2
"asset_face"."id" = $2
-- PersonRepository.getForPeopleDelete
select

View File

@@ -2,19 +2,19 @@
-- SearchRepository.searchMetadata
select
"assets".*
"asset".*
from
"assets"
inner join "exif" on "assets"."id" = "exif"."assetId"
"asset"
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
where
"assets"."visibility" = $1
and "assets"."fileCreatedAt" >= $2
and "exif"."lensModel" = $3
and "assets"."ownerId" = any ($4::uuid[])
and "assets"."isFavorite" = $5
and "assets"."deletedAt" is null
"asset"."visibility" = $1
and "asset"."fileCreatedAt" >= $2
and "asset_exif"."lensModel" = $3
and "asset"."ownerId" = any ($4::uuid[])
and "asset"."isFavorite" = $5
and "asset"."deletedAt" is null
order by
"assets"."fileCreatedAt" desc
"asset"."fileCreatedAt" desc
limit
$6
offset
@@ -24,31 +24,31 @@ offset
select
count(*) as "total"
from
"assets"
inner join "exif" on "assets"."id" = "exif"."assetId"
"asset"
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
where
"assets"."visibility" = $1
and "assets"."fileCreatedAt" >= $2
and "exif"."lensModel" = $3
and "assets"."ownerId" = any ($4::uuid[])
and "assets"."isFavorite" = $5
and "assets"."deletedAt" is null
"asset"."visibility" = $1
and "asset"."fileCreatedAt" >= $2
and "asset_exif"."lensModel" = $3
and "asset"."ownerId" = any ($4::uuid[])
and "asset"."isFavorite" = $5
and "asset"."deletedAt" is null
-- SearchRepository.searchRandom
(
select
"assets".*
"asset".*
from
"assets"
inner join "exif" on "assets"."id" = "exif"."assetId"
"asset"
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
where
"assets"."visibility" = $1
and "assets"."fileCreatedAt" >= $2
and "exif"."lensModel" = $3
and "assets"."ownerId" = any ($4::uuid[])
and "assets"."isFavorite" = $5
and "assets"."deletedAt" is null
and "assets"."id" < $6
"asset"."visibility" = $1
and "asset"."fileCreatedAt" >= $2
and "asset_exif"."lensModel" = $3
and "asset"."ownerId" = any ($4::uuid[])
and "asset"."isFavorite" = $5
and "asset"."deletedAt" is null
and "asset"."id" < $6
order by
random()
limit
@@ -57,18 +57,18 @@ where
union all
(
select
"assets".*
"asset".*
from
"assets"
inner join "exif" on "assets"."id" = "exif"."assetId"
"asset"
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
where
"assets"."visibility" = $8
and "assets"."fileCreatedAt" >= $9
and "exif"."lensModel" = $10
and "assets"."ownerId" = any ($11::uuid[])
and "assets"."isFavorite" = $12
and "assets"."deletedAt" is null
and "assets"."id" > $13
"asset"."visibility" = $8
and "asset"."fileCreatedAt" >= $9
and "asset_exif"."lensModel" = $10
and "asset"."ownerId" = any ($11::uuid[])
and "asset"."isFavorite" = $12
and "asset"."deletedAt" is null
and "asset"."id" > $13
order by
random()
limit
@@ -82,18 +82,18 @@ begin
set
local vchordrq.probes = 1
select
"assets".*
"asset".*
from
"assets"
inner join "exif" on "assets"."id" = "exif"."assetId"
inner join "smart_search" on "assets"."id" = "smart_search"."assetId"
"asset"
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
inner join "smart_search" on "asset"."id" = "smart_search"."assetId"
where
"assets"."visibility" = $1
and "assets"."fileCreatedAt" >= $2
and "exif"."lensModel" = $3
and "assets"."ownerId" = any ($4::uuid[])
and "assets"."isFavorite" = $5
and "assets"."deletedAt" is null
"asset"."visibility" = $1
and "asset"."fileCreatedAt" >= $2
and "asset_exif"."lensModel" = $3
and "asset"."ownerId" = any ($4::uuid[])
and "asset"."isFavorite" = $5
and "asset"."deletedAt" is null
order by
smart_search.embedding <=> $6
limit
@@ -109,17 +109,17 @@ set
with
"cte" as (
select
"asset_faces"."id",
"asset_faces"."personId",
"asset_face"."id",
"asset_face"."personId",
face_search.embedding <=> $1 as "distance"
from
"asset_faces"
inner join "assets" on "assets"."id" = "asset_faces"."assetId"
inner join "face_search" on "face_search"."faceId" = "asset_faces"."id"
left join "person" on "person"."id" = "asset_faces"."personId"
"asset_face"
inner join "asset" on "asset"."id" = "asset_face"."assetId"
inner join "face_search" on "face_search"."faceId" = "asset_face"."id"
left join "person" on "person"."id" = "asset_face"."personId"
where
"assets"."ownerId" = any ($2::uuid[])
and "assets"."deletedAt" is null
"asset"."ownerId" = any ($2::uuid[])
and "asset"."deletedAt" is null
order by
"distance"
limit
@@ -165,13 +165,13 @@ with recursive
"city",
"assetId"
from
"exif"
inner join "assets" on "assets"."id" = "exif"."assetId"
"asset_exif"
inner join "asset" on "asset"."id" = "asset_exif"."assetId"
where
"assets"."ownerId" = any ($1::uuid[])
and "assets"."visibility" = $2
and "assets"."type" = $3
and "assets"."deletedAt" is null
"asset"."ownerId" = any ($1::uuid[])
and "asset"."visibility" = $2
and "asset"."type" = $3
and "asset"."deletedAt" is null
order by
"city"
limit
@@ -189,14 +189,14 @@ with recursive
"city",
"assetId"
from
"exif"
inner join "assets" on "assets"."id" = "exif"."assetId"
"asset_exif"
inner join "asset" on "asset"."id" = "asset_exif"."assetId"
where
"assets"."ownerId" = any ($5::uuid[])
and "assets"."visibility" = $6
and "assets"."type" = $7
and "assets"."deletedAt" is null
and "exif"."city" > "cte"."city"
"asset"."ownerId" = any ($5::uuid[])
and "asset"."visibility" = $6
and "asset"."type" = $7
and "asset"."deletedAt" is null
and "asset_exif"."city" > "cte"."city"
order by
"city"
limit
@@ -205,21 +205,21 @@ with recursive
)
)
select
"assets".*,
to_jsonb("exif") as "exifInfo"
"asset".*,
to_jsonb("asset_exif") as "exifInfo"
from
"assets"
inner join "exif" on "assets"."id" = "exif"."assetId"
inner join "cte" on "assets"."id" = "cte"."assetId"
"asset"
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
inner join "cte" on "asset"."id" = "cte"."assetId"
order by
"exif"."city"
"asset_exif"."city"
-- SearchRepository.getStates
select distinct
on ("state") "state"
from
"exif"
inner join "assets" on "assets"."id" = "exif"."assetId"
"asset_exif"
inner join "asset" on "asset"."id" = "asset_exif"."assetId"
where
"ownerId" = any ($1::uuid[])
and "visibility" = $2
@@ -230,8 +230,8 @@ where
select distinct
on ("city") "city"
from
"exif"
inner join "assets" on "assets"."id" = "exif"."assetId"
"asset_exif"
inner join "asset" on "asset"."id" = "asset_exif"."assetId"
where
"ownerId" = any ($1::uuid[])
and "visibility" = $2
@@ -242,8 +242,8 @@ where
select distinct
on ("make") "make"
from
"exif"
inner join "assets" on "assets"."id" = "exif"."assetId"
"asset_exif"
inner join "asset" on "asset"."id" = "asset_exif"."assetId"
where
"ownerId" = any ($1::uuid[])
and "visibility" = $2
@@ -254,8 +254,8 @@ where
select distinct
on ("model") "model"
from
"exif"
inner join "assets" on "assets"."id" = "exif"."assetId"
"asset_exif"
inner join "asset" on "asset"."id" = "asset_exif"."assetId"
where
"ownerId" = any ($1::uuid[])
and "visibility" = $2

View File

@@ -6,68 +6,68 @@ select
"expiresAt",
"pinExpiresAt"
from
"sessions"
"session"
where
"id" = $1
-- SessionRepository.getByToken
select
"sessions"."id",
"sessions"."isPendingSyncReset",
"sessions"."updatedAt",
"sessions"."pinExpiresAt",
"session"."id",
"session"."isPendingSyncReset",
"session"."updatedAt",
"session"."pinExpiresAt",
(
select
to_json(obj)
from
(
select
"users"."id",
"users"."name",
"users"."email",
"users"."isAdmin",
"users"."quotaUsageInBytes",
"users"."quotaSizeInBytes"
"user"."id",
"user"."name",
"user"."email",
"user"."isAdmin",
"user"."quotaUsageInBytes",
"user"."quotaSizeInBytes"
from
"users"
"user"
where
"users"."id" = "sessions"."userId"
and "users"."deletedAt" is null
"user"."id" = "session"."userId"
and "user"."deletedAt" is null
) as obj
) as "user"
from
"sessions"
"session"
where
"sessions"."token" = $1
"session"."token" = $1
and (
"sessions"."expiresAt" is null
or "sessions"."expiresAt" > $2
"session"."expiresAt" is null
or "session"."expiresAt" > $2
)
-- SessionRepository.getByUserId
select
"sessions".*
"session".*
from
"sessions"
inner join "users" on "users"."id" = "sessions"."userId"
and "users"."deletedAt" is null
"session"
inner join "user" on "user"."id" = "session"."userId"
and "user"."deletedAt" is null
where
"sessions"."userId" = $1
"session"."userId" = $1
and (
"sessions"."expiresAt" is null
or "sessions"."expiresAt" > $2
"session"."expiresAt" is null
or "session"."expiresAt" > $2
)
order by
"sessions"."updatedAt" desc,
"sessions"."createdAt" desc
"session"."updatedAt" desc,
"session"."createdAt" desc
-- SessionRepository.delete
delete from "sessions"
delete from "session"
where
"id" = $1::uuid
-- SessionRepository.lockAll
update "sessions"
update "session"
set
"pinExpiresAt" = $1
where
@@ -75,12 +75,12 @@ where
-- SessionRepository.resetSyncProgress
begin
update "sessions"
update "session"
set
"isPendingSyncReset" = $1
where
"id" = $2
delete from "session_sync_checkpoints"
delete from "session_sync_checkpoint"
where
"sessionId" = $1
commit

View File

@@ -2,7 +2,7 @@
-- SharedLinkRepository.get
select
"shared_links".*,
"shared_link".*,
coalesce(
json_agg("a") filter (
where
@@ -12,31 +12,31 @@ select
) as "assets",
to_json("album") as "album"
from
"shared_links"
"shared_link"
left join lateral (
select
"assets".*,
"asset".*,
to_json("exifInfo") as "exifInfo"
from
"shared_link__asset"
inner join "assets" on "assets"."id" = "shared_link__asset"."assetsId"
"shared_link_asset"
inner join "asset" on "asset"."id" = "shared_link_asset"."assetsId"
inner join lateral (
select
"exif".*
"asset_exif".*
from
"exif"
"asset_exif"
where
"exif"."assetId" = "assets"."id"
"asset_exif"."assetId" = "asset"."id"
) as "exifInfo" on true
where
"shared_links"."id" = "shared_link__asset"."sharedLinksId"
and "assets"."deletedAt" is null
"shared_link"."id" = "shared_link_asset"."sharedLinksId"
and "asset"."deletedAt" is null
order by
"assets"."fileCreatedAt" asc
"asset"."fileCreatedAt" asc
) as "a" on true
left join lateral (
select
"albums".*,
"album".*,
coalesce(
json_agg("assets") filter (
where
@@ -46,151 +46,151 @@ from
) as "assets",
to_json("owner") as "owner"
from
"albums"
left join "albums_assets_assets" on "albums_assets_assets"."albumsId" = "albums"."id"
"album"
left join "album_asset" on "album_asset"."albumsId" = "album"."id"
left join lateral (
select
"assets".*,
to_json("assets_exifInfo") as "exifInfo"
"asset".*,
to_json("exifInfo") as "exifInfo"
from
"assets"
"asset"
inner join lateral (
select
"exif".*
"asset_exif".*
from
"exif"
"asset_exif"
where
"exif"."assetId" = "assets"."id"
) as "assets_exifInfo" on true
"asset_exif"."assetId" = "asset"."id"
) as "exifInfo" on true
where
"albums_assets_assets"."assetsId" = "assets"."id"
and "assets"."deletedAt" is null
"album_asset"."assetsId" = "asset"."id"
and "asset"."deletedAt" is null
order by
"assets"."fileCreatedAt" asc
"asset"."fileCreatedAt" asc
) as "assets" on true
inner join lateral (
select
"users".*
"user".*
from
"users"
"user"
where
"users"."id" = "albums"."ownerId"
and "users"."deletedAt" is null
"user"."id" = "album"."ownerId"
and "user"."deletedAt" is null
) as "owner" on true
where
"albums"."id" = "shared_links"."albumId"
and "albums"."deletedAt" is null
"album"."id" = "shared_link"."albumId"
and "album"."deletedAt" is null
group by
"albums"."id",
"album"."id",
"owner".*
) as "album" on true
where
"shared_links"."id" = $1
and "shared_links"."userId" = $2
"shared_link"."id" = $1
and "shared_link"."userId" = $2
and (
"shared_links"."type" = $3
"shared_link"."type" = $3
or "album"."id" is not null
)
group by
"shared_links"."id",
"shared_link"."id",
"album".*
order by
"shared_links"."createdAt" desc
"shared_link"."createdAt" desc
-- SharedLinkRepository.getAll
select distinct
on ("shared_links"."createdAt") "shared_links".*,
on ("shared_link"."createdAt") "shared_link".*,
"assets"."assets",
to_json("album") as "album"
from
"shared_links"
left join "shared_link__asset" on "shared_link__asset"."sharedLinksId" = "shared_links"."id"
"shared_link"
left join "shared_link_asset" on "shared_link_asset"."sharedLinksId" = "shared_link"."id"
left join lateral (
select
json_agg("assets") as "assets"
json_agg("asset") as "assets"
from
"assets"
"asset"
where
"assets"."id" = "shared_link__asset"."assetsId"
and "assets"."deletedAt" is null
"asset"."id" = "shared_link_asset"."assetsId"
and "asset"."deletedAt" is null
) as "assets" on true
left join lateral (
select
"albums".*,
"album".*,
to_json("owner") as "owner"
from
"albums"
"album"
inner join lateral (
select
"users"."id",
"users"."email",
"users"."createdAt",
"users"."profileImagePath",
"users"."isAdmin",
"users"."shouldChangePassword",
"users"."deletedAt",
"users"."oauthId",
"users"."updatedAt",
"users"."storageLabel",
"users"."name",
"users"."quotaSizeInBytes",
"users"."quotaUsageInBytes",
"users"."status",
"users"."profileChangedAt"
"user"."id",
"user"."email",
"user"."createdAt",
"user"."profileImagePath",
"user"."isAdmin",
"user"."shouldChangePassword",
"user"."deletedAt",
"user"."oauthId",
"user"."updatedAt",
"user"."storageLabel",
"user"."name",
"user"."quotaSizeInBytes",
"user"."quotaUsageInBytes",
"user"."status",
"user"."profileChangedAt"
from
"users"
"user"
where
"users"."id" = "albums"."ownerId"
and "users"."deletedAt" is null
"user"."id" = "album"."ownerId"
and "user"."deletedAt" is null
) as "owner" on true
where
"albums"."id" = "shared_links"."albumId"
and "albums"."deletedAt" is null
"album"."id" = "shared_link"."albumId"
and "album"."deletedAt" is null
) as "album" on true
where
"shared_links"."userId" = $1
"shared_link"."userId" = $1
and (
"shared_links"."type" = $2
"shared_link"."type" = $2
or "album"."id" is not null
)
and "shared_links"."albumId" = $3
and "shared_link"."albumId" = $3
order by
"shared_links"."createdAt" desc
"shared_link"."createdAt" desc
-- SharedLinkRepository.getByKey
select
"shared_links"."id",
"shared_links"."userId",
"shared_links"."expiresAt",
"shared_links"."showExif",
"shared_links"."allowUpload",
"shared_links"."allowDownload",
"shared_links"."password",
"shared_link"."id",
"shared_link"."userId",
"shared_link"."expiresAt",
"shared_link"."showExif",
"shared_link"."allowUpload",
"shared_link"."allowDownload",
"shared_link"."password",
(
select
to_json(obj)
from
(
select
"users"."id",
"users"."name",
"users"."email",
"users"."isAdmin",
"users"."quotaUsageInBytes",
"users"."quotaSizeInBytes"
"user"."id",
"user"."name",
"user"."email",
"user"."isAdmin",
"user"."quotaUsageInBytes",
"user"."quotaSizeInBytes"
from
"users"
"user"
where
"users"."id" = "shared_links"."userId"
"user"."id" = "shared_link"."userId"
) as obj
) as "user"
from
"shared_links"
left join "albums" on "albums"."id" = "shared_links"."albumId"
"shared_link"
left join "album" on "album"."id" = "shared_link"."albumId"
where
"shared_links"."key" = $1
and "albums"."deletedAt" is null
"shared_link"."key" = $1
and "album"."deletedAt" is null
and (
"shared_links"."type" = $2
or "albums"."id" is not null
"shared_link"."type" = $2
or "album"."id" is not null
)

View File

@@ -2,66 +2,66 @@
-- StackRepository.search
select
"asset_stack".*,
"stack".*,
(
select
coalesce(json_agg(agg), '[]')
from
(
select
"assets".*,
"asset".*,
to_json("exifInfo") as "exifInfo"
from
"assets"
"asset"
inner join lateral (
select
"exif"."assetId",
"exif"."autoStackId",
"exif"."bitsPerSample",
"exif"."city",
"exif"."colorspace",
"exif"."country",
"exif"."dateTimeOriginal",
"exif"."description",
"exif"."exifImageHeight",
"exif"."exifImageWidth",
"exif"."exposureTime",
"exif"."fileSizeInByte",
"exif"."fNumber",
"exif"."focalLength",
"exif"."fps",
"exif"."iso",
"exif"."latitude",
"exif"."lensModel",
"exif"."livePhotoCID",
"exif"."longitude",
"exif"."make",
"exif"."model",
"exif"."modifyDate",
"exif"."orientation",
"exif"."profileDescription",
"exif"."projectionType",
"exif"."rating",
"exif"."state",
"exif"."timeZone"
"asset_exif"."assetId",
"asset_exif"."autoStackId",
"asset_exif"."bitsPerSample",
"asset_exif"."city",
"asset_exif"."colorspace",
"asset_exif"."country",
"asset_exif"."dateTimeOriginal",
"asset_exif"."description",
"asset_exif"."exifImageHeight",
"asset_exif"."exifImageWidth",
"asset_exif"."exposureTime",
"asset_exif"."fileSizeInByte",
"asset_exif"."fNumber",
"asset_exif"."focalLength",
"asset_exif"."fps",
"asset_exif"."iso",
"asset_exif"."latitude",
"asset_exif"."lensModel",
"asset_exif"."livePhotoCID",
"asset_exif"."longitude",
"asset_exif"."make",
"asset_exif"."model",
"asset_exif"."modifyDate",
"asset_exif"."orientation",
"asset_exif"."profileDescription",
"asset_exif"."projectionType",
"asset_exif"."rating",
"asset_exif"."state",
"asset_exif"."timeZone"
from
"exif"
"asset_exif"
where
"exif"."assetId" = "assets"."id"
"asset_exif"."assetId" = "asset"."id"
) as "exifInfo" on true
where
"assets"."deletedAt" is null
and "assets"."stackId" = "asset_stack"."id"
and "assets"."visibility" in ('archive', 'timeline')
"asset"."deletedAt" is null
and "asset"."stackId" = "stack"."id"
and "asset"."visibility" in ('archive', 'timeline')
) as agg
) as "assets"
from
"asset_stack"
"stack"
where
"asset_stack"."ownerId" = $1
"stack"."ownerId" = $1
-- StackRepository.delete
delete from "asset_stack"
delete from "stack"
where
"id" = $1::uuid
@@ -74,72 +74,72 @@ select
from
(
select
"assets".*,
"asset".*,
(
select
coalesce(json_agg(agg), '[]')
from
(
select
"tags"."id",
"tags"."value",
"tags"."createdAt",
"tags"."updatedAt",
"tags"."color",
"tags"."parentId"
"tag"."id",
"tag"."value",
"tag"."createdAt",
"tag"."updatedAt",
"tag"."color",
"tag"."parentId"
from
"tags"
inner join "tag_asset" on "tags"."id" = "tag_asset"."tagsId"
"tag"
inner join "tag_asset" on "tag"."id" = "tag_asset"."tagsId"
where
"tag_asset"."assetsId" = "assets"."id"
"tag_asset"."assetsId" = "asset"."id"
) as agg
) as "tags",
to_json("exifInfo") as "exifInfo"
from
"assets"
"asset"
inner join lateral (
select
"exif"."assetId",
"exif"."autoStackId",
"exif"."bitsPerSample",
"exif"."city",
"exif"."colorspace",
"exif"."country",
"exif"."dateTimeOriginal",
"exif"."description",
"exif"."exifImageHeight",
"exif"."exifImageWidth",
"exif"."exposureTime",
"exif"."fileSizeInByte",
"exif"."fNumber",
"exif"."focalLength",
"exif"."fps",
"exif"."iso",
"exif"."latitude",
"exif"."lensModel",
"exif"."livePhotoCID",
"exif"."longitude",
"exif"."make",
"exif"."model",
"exif"."modifyDate",
"exif"."orientation",
"exif"."profileDescription",
"exif"."projectionType",
"exif"."rating",
"exif"."state",
"exif"."timeZone"
"asset_exif"."assetId",
"asset_exif"."autoStackId",
"asset_exif"."bitsPerSample",
"asset_exif"."city",
"asset_exif"."colorspace",
"asset_exif"."country",
"asset_exif"."dateTimeOriginal",
"asset_exif"."description",
"asset_exif"."exifImageHeight",
"asset_exif"."exifImageWidth",
"asset_exif"."exposureTime",
"asset_exif"."fileSizeInByte",
"asset_exif"."fNumber",
"asset_exif"."focalLength",
"asset_exif"."fps",
"asset_exif"."iso",
"asset_exif"."latitude",
"asset_exif"."lensModel",
"asset_exif"."livePhotoCID",
"asset_exif"."longitude",
"asset_exif"."make",
"asset_exif"."model",
"asset_exif"."modifyDate",
"asset_exif"."orientation",
"asset_exif"."profileDescription",
"asset_exif"."projectionType",
"asset_exif"."rating",
"asset_exif"."state",
"asset_exif"."timeZone"
from
"exif"
"asset_exif"
where
"exif"."assetId" = "assets"."id"
"asset_exif"."assetId" = "asset"."id"
) as "exifInfo" on true
where
"assets"."deletedAt" is null
and "assets"."stackId" = "asset_stack"."id"
and "assets"."visibility" in ('archive', 'timeline')
"asset"."deletedAt" is null
and "asset"."stackId" = "stack"."id"
and "asset"."visibility" in ('archive', 'timeline')
) as agg
) as "assets"
from
"asset_stack"
"stack"
where
"id" = $1::uuid

View File

@@ -5,11 +5,11 @@ select
"type",
"ack"
from
"session_sync_checkpoints"
"session_sync_checkpoint"
where
"sessionId" = $1
-- SyncCheckpointRepository.deleteAll
delete from "session_sync_checkpoints"
delete from "session_sync_checkpoint"
where
"sessionId" = $1

View File

@@ -5,7 +5,7 @@ select
"albumsId" as "id",
"createId"
from
"albums_shared_users_users"
"album_user"
where
"usersId" = $1
and "createId" >= $2
@@ -18,7 +18,7 @@ select
"id",
"albumId"
from
"albums_audit"
"album_audit"
where
"userId" = $1
and "deletedAt" < now() - interval '1 millisecond'
@@ -27,165 +27,165 @@ order by
-- SyncRepository.album.getUpserts
select distinct
on ("albums"."id", "albums"."updateId") "albums"."id",
"albums"."ownerId",
"albums"."albumName" as "name",
"albums"."description",
"albums"."createdAt",
"albums"."updatedAt",
"albums"."albumThumbnailAssetId" as "thumbnailAssetId",
"albums"."isActivityEnabled",
"albums"."order",
"albums"."updateId"
on ("album"."id", "album"."updateId") "album"."id",
"album"."ownerId",
"album"."albumName" as "name",
"album"."description",
"album"."createdAt",
"album"."updatedAt",
"album"."albumThumbnailAssetId" as "thumbnailAssetId",
"album"."isActivityEnabled",
"album"."order",
"album"."updateId"
from
"albums"
left join "albums_shared_users_users" as "album_users" on "albums"."id" = "album_users"."albumsId"
"album"
left join "album_user" as "album_users" on "album"."id" = "album_users"."albumsId"
where
"albums"."updatedAt" < now() - interval '1 millisecond'
"album"."updatedAt" < now() - interval '1 millisecond'
and (
"albums"."ownerId" = $1
"album"."ownerId" = $1
or "album_users"."usersId" = $2
)
order by
"albums"."updateId" asc
"album"."updateId" asc
-- SyncRepository.albumAsset.getBackfill
select
"assets"."id",
"assets"."ownerId",
"assets"."originalFileName",
"assets"."thumbhash",
"assets"."checksum",
"assets"."fileCreatedAt",
"assets"."fileModifiedAt",
"assets"."localDateTime",
"assets"."type",
"assets"."deletedAt",
"assets"."isFavorite",
"assets"."visibility",
"assets"."duration",
"assets"."updateId"
"asset"."id",
"asset"."ownerId",
"asset"."originalFileName",
"asset"."thumbhash",
"asset"."checksum",
"asset"."fileCreatedAt",
"asset"."fileModifiedAt",
"asset"."localDateTime",
"asset"."type",
"asset"."deletedAt",
"asset"."isFavorite",
"asset"."visibility",
"asset"."duration",
"asset"."updateId"
from
"assets"
inner join "albums_assets_assets" as "album_assets" on "album_assets"."assetsId" = "assets"."id"
"asset"
inner join "album_asset" on "album_asset"."assetsId" = "asset"."id"
where
"album_assets"."albumsId" = $1
and "assets"."updatedAt" < now() - interval '1 millisecond'
and "assets"."updateId" <= $2
and "assets"."updateId" >= $3
"album_asset"."albumsId" = $1
and "asset"."updatedAt" < now() - interval '1 millisecond'
and "asset"."updateId" <= $2
and "asset"."updateId" >= $3
order by
"assets"."updateId" asc
"asset"."updateId" asc
-- SyncRepository.albumAsset.getUpserts
select
"assets"."id",
"assets"."ownerId",
"assets"."originalFileName",
"assets"."thumbhash",
"assets"."checksum",
"assets"."fileCreatedAt",
"assets"."fileModifiedAt",
"assets"."localDateTime",
"assets"."type",
"assets"."deletedAt",
"assets"."isFavorite",
"assets"."visibility",
"assets"."duration",
"assets"."updateId"
"asset"."id",
"asset"."ownerId",
"asset"."originalFileName",
"asset"."thumbhash",
"asset"."checksum",
"asset"."fileCreatedAt",
"asset"."fileModifiedAt",
"asset"."localDateTime",
"asset"."type",
"asset"."deletedAt",
"asset"."isFavorite",
"asset"."visibility",
"asset"."duration",
"asset"."updateId"
from
"assets"
inner join "albums_assets_assets" as "album_assets" on "album_assets"."assetsId" = "assets"."id"
inner join "albums" on "albums"."id" = "album_assets"."albumsId"
left join "albums_shared_users_users" as "album_users" on "album_users"."albumsId" = "album_assets"."albumsId"
"asset"
inner join "album_asset" on "album_asset"."assetsId" = "asset"."id"
inner join "album" on "album"."id" = "album_asset"."albumsId"
left join "album_user" on "album_user"."albumsId" = "album_asset"."albumsId"
where
"assets"."updatedAt" < now() - interval '1 millisecond'
"asset"."updatedAt" < now() - interval '1 millisecond'
and (
"albums"."ownerId" = $1
or "album_users"."usersId" = $2
"album"."ownerId" = $1
or "album_user"."usersId" = $2
)
order by
"assets"."updateId" asc
"asset"."updateId" asc
-- SyncRepository.albumAssetExif.getBackfill
select
"exif"."assetId",
"exif"."description",
"exif"."exifImageWidth",
"exif"."exifImageHeight",
"exif"."fileSizeInByte",
"exif"."orientation",
"exif"."dateTimeOriginal",
"exif"."modifyDate",
"exif"."timeZone",
"exif"."latitude",
"exif"."longitude",
"exif"."projectionType",
"exif"."city",
"exif"."state",
"exif"."country",
"exif"."make",
"exif"."model",
"exif"."lensModel",
"exif"."fNumber",
"exif"."focalLength",
"exif"."iso",
"exif"."exposureTime",
"exif"."profileDescription",
"exif"."rating",
"exif"."fps",
"exif"."updateId"
"asset_exif"."assetId",
"asset_exif"."description",
"asset_exif"."exifImageWidth",
"asset_exif"."exifImageHeight",
"asset_exif"."fileSizeInByte",
"asset_exif"."orientation",
"asset_exif"."dateTimeOriginal",
"asset_exif"."modifyDate",
"asset_exif"."timeZone",
"asset_exif"."latitude",
"asset_exif"."longitude",
"asset_exif"."projectionType",
"asset_exif"."city",
"asset_exif"."state",
"asset_exif"."country",
"asset_exif"."make",
"asset_exif"."model",
"asset_exif"."lensModel",
"asset_exif"."fNumber",
"asset_exif"."focalLength",
"asset_exif"."iso",
"asset_exif"."exposureTime",
"asset_exif"."profileDescription",
"asset_exif"."rating",
"asset_exif"."fps",
"asset_exif"."updateId"
from
"exif"
inner join "albums_assets_assets" as "album_assets" on "album_assets"."assetsId" = "exif"."assetId"
"asset_exif"
inner join "album_asset" on "album_asset"."assetsId" = "asset_exif"."assetId"
where
"album_assets"."albumsId" = $1
and "exif"."updatedAt" < now() - interval '1 millisecond'
and "exif"."updateId" <= $2
and "exif"."updateId" >= $3
"album_asset"."albumsId" = $1
and "asset_exif"."updatedAt" < now() - interval '1 millisecond'
and "asset_exif"."updateId" <= $2
and "asset_exif"."updateId" >= $3
order by
"exif"."updateId" asc
"asset_exif"."updateId" asc
-- SyncRepository.albumAssetExif.getUpserts
select
"exif"."assetId",
"exif"."description",
"exif"."exifImageWidth",
"exif"."exifImageHeight",
"exif"."fileSizeInByte",
"exif"."orientation",
"exif"."dateTimeOriginal",
"exif"."modifyDate",
"exif"."timeZone",
"exif"."latitude",
"exif"."longitude",
"exif"."projectionType",
"exif"."city",
"exif"."state",
"exif"."country",
"exif"."make",
"exif"."model",
"exif"."lensModel",
"exif"."fNumber",
"exif"."focalLength",
"exif"."iso",
"exif"."exposureTime",
"exif"."profileDescription",
"exif"."rating",
"exif"."fps",
"exif"."updateId"
"asset_exif"."assetId",
"asset_exif"."description",
"asset_exif"."exifImageWidth",
"asset_exif"."exifImageHeight",
"asset_exif"."fileSizeInByte",
"asset_exif"."orientation",
"asset_exif"."dateTimeOriginal",
"asset_exif"."modifyDate",
"asset_exif"."timeZone",
"asset_exif"."latitude",
"asset_exif"."longitude",
"asset_exif"."projectionType",
"asset_exif"."city",
"asset_exif"."state",
"asset_exif"."country",
"asset_exif"."make",
"asset_exif"."model",
"asset_exif"."lensModel",
"asset_exif"."fNumber",
"asset_exif"."focalLength",
"asset_exif"."iso",
"asset_exif"."exposureTime",
"asset_exif"."profileDescription",
"asset_exif"."rating",
"asset_exif"."fps",
"asset_exif"."updateId"
from
"exif"
inner join "albums_assets_assets" as "album_assets" on "album_assets"."assetsId" = "exif"."assetId"
inner join "albums" on "albums"."id" = "album_assets"."albumsId"
left join "albums_shared_users_users" as "album_users" on "album_users"."albumsId" = "album_assets"."albumsId"
"asset_exif"
inner join "album_asset" on "album_asset"."assetsId" = "asset_exif"."assetId"
inner join "album" on "album"."id" = "album_asset"."albumsId"
left join "album_user" on "album_user"."albumsId" = "album_asset"."albumsId"
where
"exif"."updatedAt" < now() - interval '1 millisecond'
"asset_exif"."updatedAt" < now() - interval '1 millisecond'
and (
"albums"."ownerId" = $1
or "album_users"."usersId" = $2
"album"."ownerId" = $1
or "album_user"."usersId" = $2
)
order by
"exif"."updateId" asc
"asset_exif"."updateId" asc
-- SyncRepository.albumToAsset.getBackfill
select
@@ -193,7 +193,7 @@ select
"album_assets"."albumsId" as "albumId",
"album_assets"."updateId"
from
"albums_assets_assets" as "album_assets"
"album_asset" as "album_assets"
where
"album_assets"."albumsId" = $1
and "album_assets"."updatedAt" < now() - interval '1 millisecond'
@@ -208,23 +208,23 @@ select
"assetId",
"albumId"
from
"album_assets_audit"
"album_asset_audit"
where
"albumId" in (
select
"id"
from
"albums"
"album"
where
"ownerId" = $1
union
(
select
"albumUsers"."albumsId" as "id"
"album_user"."albumsId" as "id"
from
"albums_shared_users_users" as "albumUsers"
"album_user"
where
"albumUsers"."usersId" = $2
"album_user"."usersId" = $2
)
)
and "deletedAt" < now() - interval '1 millisecond'
@@ -233,30 +233,30 @@ order by
-- SyncRepository.albumToAsset.getUpserts
select
"album_assets"."assetsId" as "assetId",
"album_assets"."albumsId" as "albumId",
"album_assets"."updateId"
"album_asset"."assetsId" as "assetId",
"album_asset"."albumsId" as "albumId",
"album_asset"."updateId"
from
"albums_assets_assets" as "album_assets"
inner join "albums" on "albums"."id" = "album_assets"."albumsId"
left join "albums_shared_users_users" as "album_users" on "album_users"."albumsId" = "album_assets"."albumsId"
"album_asset"
inner join "album" on "album"."id" = "album_asset"."albumsId"
left join "album_user" on "album_user"."albumsId" = "album_asset"."albumsId"
where
"album_assets"."updatedAt" < now() - interval '1 millisecond'
"album_asset"."updatedAt" < now() - interval '1 millisecond'
and (
"albums"."ownerId" = $1
or "album_users"."usersId" = $2
"album"."ownerId" = $1
or "album_user"."usersId" = $2
)
order by
"album_assets"."updateId" asc
"album_asset"."updateId" asc
-- SyncRepository.albumUser.getBackfill
select
"album_users"."albumsId" as "albumId",
"album_users"."usersId" as "userId",
"album_users"."role",
"album_users"."updateId"
"album_user"."albumsId" as "albumId",
"album_user"."usersId" as "userId",
"album_user"."role",
"album_user"."updateId"
from
"albums_shared_users_users" as "album_users"
"album_user"
where
"albumsId" = $1
and "updatedAt" < now() - interval '1 millisecond'
@@ -271,23 +271,23 @@ select
"userId",
"albumId"
from
"album_users_audit"
"album_user_audit"
where
"albumId" in (
select
"id"
from
"albums"
"album"
where
"ownerId" = $1
union
(
select
"albumUsers"."albumsId" as "id"
"album_user"."albumsId" as "id"
from
"albums_shared_users_users" as "albumUsers"
"album_user"
where
"albumUsers"."usersId" = $2
"album_user"."usersId" = $2
)
)
and "deletedAt" < now() - interval '1 millisecond'
@@ -296,19 +296,19 @@ order by
-- SyncRepository.albumUser.getUpserts
select
"album_users"."albumsId" as "albumId",
"album_users"."usersId" as "userId",
"album_users"."role",
"album_users"."updateId"
"album_user"."albumsId" as "albumId",
"album_user"."usersId" as "userId",
"album_user"."role",
"album_user"."updateId"
from
"albums_shared_users_users" as "album_users"
"album_user"
where
"album_users"."updatedAt" < now() - interval '1 millisecond'
and "album_users"."albumsId" in (
"album_user"."updatedAt" < now() - interval '1 millisecond'
and "album_user"."albumsId" in (
select
"id"
from
"albums"
"album"
where
"ownerId" = $1
union
@@ -316,20 +316,20 @@ where
select
"albumUsers"."albumsId" as "id"
from
"albums_shared_users_users" as "albumUsers"
"album_user" as "albumUsers"
where
"albumUsers"."usersId" = $2
)
)
order by
"album_users"."updateId" asc
"album_user"."updateId" asc
-- SyncRepository.asset.getDeletes
select
"id",
"assetId"
from
"assets_audit"
"asset_audit"
where
"ownerId" = $1
and "deletedAt" < now() - interval '1 millisecond'
@@ -338,22 +338,22 @@ order by
-- SyncRepository.asset.getUpserts
select
"assets"."id",
"assets"."ownerId",
"assets"."originalFileName",
"assets"."thumbhash",
"assets"."checksum",
"assets"."fileCreatedAt",
"assets"."fileModifiedAt",
"assets"."localDateTime",
"assets"."type",
"assets"."deletedAt",
"assets"."isFavorite",
"assets"."visibility",
"assets"."duration",
"assets"."updateId"
"asset"."id",
"asset"."ownerId",
"asset"."originalFileName",
"asset"."thumbhash",
"asset"."checksum",
"asset"."fileCreatedAt",
"asset"."fileModifiedAt",
"asset"."localDateTime",
"asset"."type",
"asset"."deletedAt",
"asset"."isFavorite",
"asset"."visibility",
"asset"."duration",
"asset"."updateId"
from
"assets"
"asset"
where
"ownerId" = $1
and "updatedAt" < now() - interval '1 millisecond'
@@ -362,40 +362,40 @@ order by
-- SyncRepository.assetExif.getUpserts
select
"exif"."assetId",
"exif"."description",
"exif"."exifImageWidth",
"exif"."exifImageHeight",
"exif"."fileSizeInByte",
"exif"."orientation",
"exif"."dateTimeOriginal",
"exif"."modifyDate",
"exif"."timeZone",
"exif"."latitude",
"exif"."longitude",
"exif"."projectionType",
"exif"."city",
"exif"."state",
"exif"."country",
"exif"."make",
"exif"."model",
"exif"."lensModel",
"exif"."fNumber",
"exif"."focalLength",
"exif"."iso",
"exif"."exposureTime",
"exif"."profileDescription",
"exif"."rating",
"exif"."fps",
"exif"."updateId"
"asset_exif"."assetId",
"asset_exif"."description",
"asset_exif"."exifImageWidth",
"asset_exif"."exifImageHeight",
"asset_exif"."fileSizeInByte",
"asset_exif"."orientation",
"asset_exif"."dateTimeOriginal",
"asset_exif"."modifyDate",
"asset_exif"."timeZone",
"asset_exif"."latitude",
"asset_exif"."longitude",
"asset_exif"."projectionType",
"asset_exif"."city",
"asset_exif"."state",
"asset_exif"."country",
"asset_exif"."make",
"asset_exif"."model",
"asset_exif"."lensModel",
"asset_exif"."fNumber",
"asset_exif"."focalLength",
"asset_exif"."iso",
"asset_exif"."exposureTime",
"asset_exif"."profileDescription",
"asset_exif"."rating",
"asset_exif"."fps",
"asset_exif"."updateId"
from
"exif"
"asset_exif"
where
"assetId" in (
select
"id"
from
"assets"
"asset"
where
"ownerId" = $1
)
@@ -408,7 +408,7 @@ select
"id",
"memoryId"
from
"memories_audit"
"memory_audit"
where
"userId" = $1
and "deletedAt" < now() - interval '1 millisecond'
@@ -431,7 +431,7 @@ select
"hideAt",
"updateId"
from
"memories"
"memory"
where
"ownerId" = $1
and "updatedAt" < now() - interval '1 millisecond'
@@ -444,13 +444,13 @@ select
"memoryId",
"assetId"
from
"memory_assets_audit"
"memory_asset_audit"
where
"memoryId" in (
select
"id"
from
"memories"
"memory"
where
"ownerId" = $1
)
@@ -464,13 +464,13 @@ select
"assetsId" as "assetId",
"updateId"
from
"memories_assets_assets"
"memory_asset"
where
"memoriesId" in (
select
"id"
from
"memories"
"memory"
where
"ownerId" = $1
)
@@ -483,13 +483,13 @@ select
"sharedById",
"createId"
from
"partners"
"partner"
where
"sharedWithId" = $1
and "createId" >= $2
and "createdAt" < now() - interval '1 millisecond'
order by
"partners"."createId" asc
"partner"."createId" asc
-- SyncRepository.partner.getDeletes
select
@@ -497,7 +497,7 @@ select
"sharedById",
"sharedWithId"
from
"partners_audit"
"partner_audit"
where
(
"sharedById" = $1
@@ -514,7 +514,7 @@ select
"inTimeline",
"updateId"
from
"partners"
"partner"
where
(
"sharedById" = $1
@@ -526,22 +526,22 @@ order by
-- SyncRepository.partnerAsset.getBackfill
select
"assets"."id",
"assets"."ownerId",
"assets"."originalFileName",
"assets"."thumbhash",
"assets"."checksum",
"assets"."fileCreatedAt",
"assets"."fileModifiedAt",
"assets"."localDateTime",
"assets"."type",
"assets"."deletedAt",
"assets"."isFavorite",
"assets"."visibility",
"assets"."duration",
"assets"."updateId"
"asset"."id",
"asset"."ownerId",
"asset"."originalFileName",
"asset"."thumbhash",
"asset"."checksum",
"asset"."fileCreatedAt",
"asset"."fileModifiedAt",
"asset"."localDateTime",
"asset"."type",
"asset"."deletedAt",
"asset"."isFavorite",
"asset"."visibility",
"asset"."duration",
"asset"."updateId"
from
"assets"
"asset"
where
"ownerId" = $1
and "updatedAt" < now() - interval '1 millisecond'
@@ -555,13 +555,13 @@ select
"id",
"assetId"
from
"assets_audit"
"asset_audit"
where
"ownerId" in (
select
"sharedById"
from
"partners"
"partner"
where
"sharedWithId" = $1
)
@@ -571,28 +571,28 @@ order by
-- SyncRepository.partnerAsset.getUpserts
select
"assets"."id",
"assets"."ownerId",
"assets"."originalFileName",
"assets"."thumbhash",
"assets"."checksum",
"assets"."fileCreatedAt",
"assets"."fileModifiedAt",
"assets"."localDateTime",
"assets"."type",
"assets"."deletedAt",
"assets"."isFavorite",
"assets"."visibility",
"assets"."duration",
"assets"."updateId"
"asset"."id",
"asset"."ownerId",
"asset"."originalFileName",
"asset"."thumbhash",
"asset"."checksum",
"asset"."fileCreatedAt",
"asset"."fileModifiedAt",
"asset"."localDateTime",
"asset"."type",
"asset"."deletedAt",
"asset"."isFavorite",
"asset"."visibility",
"asset"."duration",
"asset"."updateId"
from
"assets"
"asset"
where
"ownerId" in (
select
"sharedById"
from
"partners"
"partner"
where
"sharedWithId" = $1
)
@@ -602,85 +602,85 @@ order by
-- SyncRepository.partnerAssetExif.getBackfill
select
"exif"."assetId",
"exif"."description",
"exif"."exifImageWidth",
"exif"."exifImageHeight",
"exif"."fileSizeInByte",
"exif"."orientation",
"exif"."dateTimeOriginal",
"exif"."modifyDate",
"exif"."timeZone",
"exif"."latitude",
"exif"."longitude",
"exif"."projectionType",
"exif"."city",
"exif"."state",
"exif"."country",
"exif"."make",
"exif"."model",
"exif"."lensModel",
"exif"."fNumber",
"exif"."focalLength",
"exif"."iso",
"exif"."exposureTime",
"exif"."profileDescription",
"exif"."rating",
"exif"."fps",
"exif"."updateId"
"asset_exif"."assetId",
"asset_exif"."description",
"asset_exif"."exifImageWidth",
"asset_exif"."exifImageHeight",
"asset_exif"."fileSizeInByte",
"asset_exif"."orientation",
"asset_exif"."dateTimeOriginal",
"asset_exif"."modifyDate",
"asset_exif"."timeZone",
"asset_exif"."latitude",
"asset_exif"."longitude",
"asset_exif"."projectionType",
"asset_exif"."city",
"asset_exif"."state",
"asset_exif"."country",
"asset_exif"."make",
"asset_exif"."model",
"asset_exif"."lensModel",
"asset_exif"."fNumber",
"asset_exif"."focalLength",
"asset_exif"."iso",
"asset_exif"."exposureTime",
"asset_exif"."profileDescription",
"asset_exif"."rating",
"asset_exif"."fps",
"asset_exif"."updateId"
from
"exif"
inner join "assets" on "assets"."id" = "exif"."assetId"
"asset_exif"
inner join "asset" on "asset"."id" = "asset_exif"."assetId"
where
"assets"."ownerId" = $1
and "exif"."updatedAt" < now() - interval '1 millisecond'
and "exif"."updateId" <= $2
and "exif"."updateId" >= $3
"asset"."ownerId" = $1
and "asset_exif"."updatedAt" < now() - interval '1 millisecond'
and "asset_exif"."updateId" <= $2
and "asset_exif"."updateId" >= $3
order by
"exif"."updateId" asc
"asset_exif"."updateId" asc
-- SyncRepository.partnerAssetExif.getUpserts
select
"exif"."assetId",
"exif"."description",
"exif"."exifImageWidth",
"exif"."exifImageHeight",
"exif"."fileSizeInByte",
"exif"."orientation",
"exif"."dateTimeOriginal",
"exif"."modifyDate",
"exif"."timeZone",
"exif"."latitude",
"exif"."longitude",
"exif"."projectionType",
"exif"."city",
"exif"."state",
"exif"."country",
"exif"."make",
"exif"."model",
"exif"."lensModel",
"exif"."fNumber",
"exif"."focalLength",
"exif"."iso",
"exif"."exposureTime",
"exif"."profileDescription",
"exif"."rating",
"exif"."fps",
"exif"."updateId"
"asset_exif"."assetId",
"asset_exif"."description",
"asset_exif"."exifImageWidth",
"asset_exif"."exifImageHeight",
"asset_exif"."fileSizeInByte",
"asset_exif"."orientation",
"asset_exif"."dateTimeOriginal",
"asset_exif"."modifyDate",
"asset_exif"."timeZone",
"asset_exif"."latitude",
"asset_exif"."longitude",
"asset_exif"."projectionType",
"asset_exif"."city",
"asset_exif"."state",
"asset_exif"."country",
"asset_exif"."make",
"asset_exif"."model",
"asset_exif"."lensModel",
"asset_exif"."fNumber",
"asset_exif"."focalLength",
"asset_exif"."iso",
"asset_exif"."exposureTime",
"asset_exif"."profileDescription",
"asset_exif"."rating",
"asset_exif"."fps",
"asset_exif"."updateId"
from
"exif"
"asset_exif"
where
"assetId" in (
select
"id"
from
"assets"
"asset"
where
"ownerId" in (
select
"sharedById"
from
"partners"
"partner"
where
"sharedWithId" = $1
)
@@ -694,13 +694,13 @@ select
"id",
"stackId"
from
"stacks_audit"
"stack_audit"
where
"userId" in (
select
"sharedById"
from
"partners"
"partner"
where
"sharedWithId" = $1
)
@@ -710,14 +710,14 @@ order by
-- SyncRepository.partnerStack.getBackfill
select
"asset_stack"."id",
"asset_stack"."createdAt",
"asset_stack"."updatedAt",
"asset_stack"."primaryAssetId",
"asset_stack"."ownerId",
"stack"."id",
"stack"."createdAt",
"stack"."updatedAt",
"stack"."primaryAssetId",
"stack"."ownerId",
"updateId"
from
"asset_stack"
"stack"
where
"ownerId" = $1
and "updatedAt" < now() - interval '1 millisecond'
@@ -728,20 +728,20 @@ order by
-- SyncRepository.partnerStack.getUpserts
select
"asset_stack"."id",
"asset_stack"."createdAt",
"asset_stack"."updatedAt",
"asset_stack"."primaryAssetId",
"asset_stack"."ownerId",
"stack"."id",
"stack"."createdAt",
"stack"."updatedAt",
"stack"."primaryAssetId",
"stack"."ownerId",
"updateId"
from
"asset_stack"
"stack"
where
"ownerId" in (
select
"sharedById"
from
"partners"
"partner"
where
"sharedWithId" = $1
)
@@ -788,7 +788,7 @@ select
"id",
"stackId"
from
"stacks_audit"
"stack_audit"
where
"userId" = $1
and "deletedAt" < now() - interval '1 millisecond'
@@ -797,14 +797,14 @@ order by
-- SyncRepository.stack.getUpserts
select
"asset_stack"."id",
"asset_stack"."createdAt",
"asset_stack"."updatedAt",
"asset_stack"."primaryAssetId",
"asset_stack"."ownerId",
"stack"."id",
"stack"."createdAt",
"stack"."updatedAt",
"stack"."primaryAssetId",
"stack"."ownerId",
"updateId"
from
"asset_stack"
"stack"
where
"ownerId" = $1
and "updatedAt" < now() - interval '1 millisecond'
@@ -816,7 +816,7 @@ select
"id",
"userId"
from
"users_audit"
"user_audit"
where
"deletedAt" < now() - interval '1 millisecond'
order by
@@ -830,7 +830,7 @@ select
"deletedAt",
"updateId"
from
"users"
"user"
where
"updatedAt" < now() - interval '1 millisecond'
order by

View File

@@ -2,27 +2,27 @@
-- TagRepository.get
select
"tags"."id",
"tags"."value",
"tags"."createdAt",
"tags"."updatedAt",
"tags"."color",
"tags"."parentId"
"tag"."id",
"tag"."value",
"tag"."createdAt",
"tag"."updatedAt",
"tag"."color",
"tag"."parentId"
from
"tags"
"tag"
where
"id" = $1
-- TagRepository.getByValue
select
"tags"."id",
"tags"."value",
"tags"."createdAt",
"tags"."updatedAt",
"tags"."color",
"tags"."parentId"
"tag"."id",
"tag"."value",
"tag"."createdAt",
"tag"."updatedAt",
"tag"."color",
"tag"."parentId"
from
"tags"
"tag"
where
"userId" = $1
and "value" = $2
@@ -30,31 +30,31 @@ where
-- TagRepository.upsertValue
begin
insert into
"tags" ("userId", "value", "parentId")
"tag" ("userId", "value", "parentId")
values
($1, $2, $3)
on conflict ("userId", "value") do update
set
"parentId" = $4
returning
"tags"."id",
"tags"."value",
"tags"."createdAt",
"tags"."updatedAt",
"tags"."color",
"tags"."parentId"
"tag"."id",
"tag"."value",
"tag"."createdAt",
"tag"."updatedAt",
"tag"."color",
"tag"."parentId"
rollback
-- TagRepository.getAll
select
"tags"."id",
"tags"."value",
"tags"."createdAt",
"tags"."updatedAt",
"tags"."color",
"tags"."parentId"
"tag"."id",
"tag"."value",
"tag"."createdAt",
"tag"."updatedAt",
"tag"."color",
"tag"."parentId"
from
"tags"
"tag"
where
"userId" = $1
order by
@@ -62,14 +62,14 @@ order by
-- TagRepository.create
insert into
"tags" ("userId", "color", "value")
"tag" ("userId", "color", "value")
values
($1, $2, $3)
returning
*
-- TagRepository.update
update "tags"
update "tag"
set
"color" = $1
where
@@ -78,7 +78,7 @@ returning
*
-- TagRepository.delete
delete from "tags"
delete from "tag"
where
"id" = $1

View File

@@ -1,7 +1,7 @@
-- NOTE: This file is auto generated by ./sql-generator
-- TrashRepository.restore
update "assets"
update "asset"
set
"status" = $1,
"deletedAt" = $2
@@ -10,7 +10,7 @@ where
and "status" = $4
-- TrashRepository.empty
update "assets"
update "asset"
set
"status" = $1
where
@@ -18,7 +18,7 @@ where
and "status" = $3
-- TrashRepository.restoreAll
update "assets"
update "asset"
set
"status" = $1,
"deletedAt" = $2

View File

@@ -30,14 +30,14 @@ select
from
"user_metadata"
where
"users"."id" = "user_metadata"."userId"
"user"."id" = "user_metadata"."userId"
) as agg
) as "metadata"
from
"users"
"user"
where
"users"."id" = $1
and "users"."deletedAt" is null
"user"."id" = $1
and "user"."deletedAt" is null
-- UserRepository.getAdmin
select
@@ -69,43 +69,43 @@ select
from
"user_metadata"
where
"users"."id" = "user_metadata"."userId"
"user"."id" = "user_metadata"."userId"
) as agg
) as "metadata"
from
"users"
"user"
where
"users"."isAdmin" = $1
and "users"."deletedAt" is null
"user"."isAdmin" = $1
and "user"."deletedAt" is null
-- UserRepository.hasAdmin
select
"users"."id"
"user"."id"
from
"users"
"user"
where
"users"."isAdmin" = $1
and "users"."deletedAt" is null
"user"."isAdmin" = $1
and "user"."deletedAt" is null
-- UserRepository.getForPinCode
select
"users"."pinCode",
"users"."password"
"user"."pinCode",
"user"."password"
from
"users"
"user"
where
"users"."id" = $1
and "users"."deletedAt" is null
"user"."id" = $1
and "user"."deletedAt" is null
-- UserRepository.getForChangePassword
select
"users"."id",
"users"."password"
"user"."id",
"user"."password"
from
"users"
"user"
where
"users"."id" = $1
and "users"."deletedAt" is null
"user"."id" = $1
and "user"."deletedAt" is null
-- UserRepository.getByEmail
select
@@ -137,14 +137,14 @@ select
from
"user_metadata"
where
"users"."id" = "user_metadata"."userId"
"user"."id" = "user_metadata"."userId"
) as agg
) as "metadata"
from
"users"
"user"
where
"email" = $1
and "users"."deletedAt" is null
and "user"."deletedAt" is null
-- UserRepository.getByStorageLabel
select
@@ -166,10 +166,10 @@ select
"quotaSizeInBytes",
"quotaUsageInBytes"
from
"users"
"user"
where
"users"."storageLabel" = $1
and "users"."deletedAt" is null
"user"."storageLabel" = $1
and "user"."deletedAt" is null
-- UserRepository.getByOAuthId
select
@@ -201,22 +201,22 @@ select
from
"user_metadata"
where
"users"."id" = "user_metadata"."userId"
"user"."id" = "user_metadata"."userId"
) as agg
) as "metadata"
from
"users"
"user"
where
"users"."oauthId" = $1
and "users"."deletedAt" is null
"user"."oauthId" = $1
and "user"."deletedAt" is null
-- UserRepository.getDeletedAfter
select
"id"
from
"users"
"user"
where
"users"."deletedAt" < $1
"user"."deletedAt" < $1
-- UserRepository.getList (with deleted)
select
@@ -248,11 +248,11 @@ select
from
"user_metadata"
where
"users"."id" = "user_metadata"."userId"
"user"."id" = "user_metadata"."userId"
) as agg
) as "metadata"
from
"users"
"user"
order by
"createdAt" desc
@@ -286,95 +286,95 @@ select
from
"user_metadata"
where
"users"."id" = "user_metadata"."userId"
"user"."id" = "user_metadata"."userId"
) as agg
) as "metadata"
from
"users"
"user"
where
"users"."deletedAt" is null
"user"."deletedAt" is null
order by
"createdAt" desc
-- UserRepository.getUserStats
select
"users"."id" as "userId",
"users"."name" as "userName",
"users"."quotaSizeInBytes",
"user"."id" as "userId",
"user"."name" as "userName",
"user"."quotaSizeInBytes",
count(*) filter (
where
(
"assets"."type" = 'IMAGE'
and "assets"."visibility" != 'hidden'
"asset"."type" = 'IMAGE'
and "asset"."visibility" != 'hidden'
)
) as "photos",
count(*) filter (
where
(
"assets"."type" = 'VIDEO'
and "assets"."visibility" != 'hidden'
"asset"."type" = 'VIDEO'
and "asset"."visibility" != 'hidden'
)
) as "videos",
coalesce(
sum("exif"."fileSizeInByte") filter (
sum("asset_exif"."fileSizeInByte") filter (
where
"assets"."libraryId" is null
"asset"."libraryId" is null
),
0
) as "usage",
coalesce(
sum("exif"."fileSizeInByte") filter (
sum("asset_exif"."fileSizeInByte") filter (
where
(
"assets"."libraryId" is null
and "assets"."type" = 'IMAGE'
"asset"."libraryId" is null
and "asset"."type" = 'IMAGE'
)
),
0
) as "usagePhotos",
coalesce(
sum("exif"."fileSizeInByte") filter (
sum("asset_exif"."fileSizeInByte") filter (
where
(
"assets"."libraryId" is null
and "assets"."type" = 'VIDEO'
"asset"."libraryId" is null
and "asset"."type" = 'VIDEO'
)
),
0
) as "usageVideos"
from
"users"
left join "assets" on "assets"."ownerId" = "users"."id"
and "assets"."deletedAt" is null
left join "exif" on "exif"."assetId" = "assets"."id"
"user"
left join "asset" on "asset"."ownerId" = "user"."id"
and "asset"."deletedAt" is null
left join "asset_exif" on "asset_exif"."assetId" = "asset"."id"
group by
"users"."id"
"user"."id"
order by
"users"."createdAt" asc
"user"."createdAt" asc
-- UserRepository.updateUsage
update "users"
update "user"
set
"quotaUsageInBytes" = "quotaUsageInBytes" + $1,
"updatedAt" = $2
where
"id" = $3::uuid
and "users"."deletedAt" is null
and "user"."deletedAt" is null
-- UserRepository.syncUsage
update "users"
update "user"
set
"quotaUsageInBytes" = (
select
coalesce(sum("exif"."fileSizeInByte"), 0) as "usage"
coalesce(sum("asset_exif"."fileSizeInByte"), 0) as "usage"
from
"assets"
left join "exif" on "exif"."assetId" = "assets"."id"
"asset"
left join "asset_exif" on "asset_exif"."assetId" = "asset"."id"
where
"assets"."libraryId" is null
and "assets"."ownerId" = "users"."id"
"asset"."libraryId" is null
and "asset"."ownerId" = "user"."id"
),
"updatedAt" = $1
where
"users"."deletedAt" is null
and "users"."id" = $2::uuid
"user"."deletedAt" is null
and "user"."id" = $2::uuid

View File

@@ -2,9 +2,9 @@
-- ViewRepository.getUniqueOriginalPaths
select distinct
substring("assets"."originalPath", $1) as "directoryPath"
substring("asset"."originalPath", $1) as "directoryPath"
from
"assets"
"asset"
where
"ownerId" = $2::uuid
and "visibility" = $3
@@ -15,11 +15,11 @@ where
-- ViewRepository.getAssetsByOriginalPath
select
"assets".*,
to_json("exif") as "exifInfo"
"asset".*,
to_json("asset_exif") as "exifInfo"
from
"assets"
left join "exif" on "assets"."id" = "exif"."assetId"
"asset"
left join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
where
"ownerId" = $1::uuid
and "visibility" = $2
@@ -30,4 +30,4 @@ where
and "originalPath" like $3
and "originalPath" not like $4
order by
regexp_replace("assets"."originalPath", $5, $6) asc
regexp_replace("asset"."originalPath", $5, $6) asc