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
+101 -101
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)