fix(server): hide isFavorite from partner asset sync stream (#28035)
* fix(server): hide isFavorite from partner asset sync stream * use new column entry instead * sync sql * add migration * use sql.val * sync sqlpull/28271/head
parent
fe2bf0c6dd
commit
7de73dc176
|
|
@ -395,6 +395,26 @@ export const columns = {
|
|||
'asset.height',
|
||||
'asset.isEdited',
|
||||
],
|
||||
syncPartnerAsset: [
|
||||
'asset.id',
|
||||
'asset.ownerId',
|
||||
'asset.originalFileName',
|
||||
'asset.thumbhash',
|
||||
'asset.checksum',
|
||||
'asset.fileCreatedAt',
|
||||
'asset.fileModifiedAt',
|
||||
'asset.localDateTime',
|
||||
'asset.type',
|
||||
'asset.deletedAt',
|
||||
'asset.visibility',
|
||||
'asset.duration',
|
||||
'asset.livePhotoVideoId',
|
||||
'asset.stackId',
|
||||
'asset.libraryId',
|
||||
'asset.width',
|
||||
'asset.height',
|
||||
'asset.isEdited',
|
||||
],
|
||||
syncAlbumUser: ['album_user.albumId as albumId', 'album_user.userId as userId', 'album_user.role'],
|
||||
syncStack: ['stack.id', 'stack.createdAt', 'stack.updatedAt', 'stack.primaryAssetId', 'stack.ownerId'],
|
||||
syncUser: ['id', 'name', 'email', 'avatarColor', 'deletedAt', 'updateId', 'profileImagePath', 'profileChangedAt'],
|
||||
|
|
|
|||
|
|
@ -739,7 +739,6 @@ select
|
|||
"asset"."localDateTime",
|
||||
"asset"."type",
|
||||
"asset"."deletedAt",
|
||||
"asset"."isFavorite",
|
||||
"asset"."visibility",
|
||||
"asset"."duration",
|
||||
"asset"."livePhotoVideoId",
|
||||
|
|
@ -748,14 +747,15 @@ select
|
|||
"asset"."width",
|
||||
"asset"."height",
|
||||
"asset"."isEdited",
|
||||
$1 as "isFavorite",
|
||||
"asset"."updateId"
|
||||
from
|
||||
"asset" as "asset"
|
||||
where
|
||||
"asset"."updateId" < $1
|
||||
and "asset"."updateId" <= $2
|
||||
and "asset"."updateId" >= $3
|
||||
and "ownerId" = $4
|
||||
"asset"."updateId" < $2
|
||||
and "asset"."updateId" <= $3
|
||||
and "asset"."updateId" >= $4
|
||||
and "ownerId" = $5
|
||||
order by
|
||||
"asset"."updateId" asc
|
||||
|
||||
|
|
@ -791,7 +791,6 @@ select
|
|||
"asset"."localDateTime",
|
||||
"asset"."type",
|
||||
"asset"."deletedAt",
|
||||
"asset"."isFavorite",
|
||||
"asset"."visibility",
|
||||
"asset"."duration",
|
||||
"asset"."livePhotoVideoId",
|
||||
|
|
@ -800,19 +799,20 @@ select
|
|||
"asset"."width",
|
||||
"asset"."height",
|
||||
"asset"."isEdited",
|
||||
$1 as "isFavorite",
|
||||
"asset"."updateId"
|
||||
from
|
||||
"asset" as "asset"
|
||||
where
|
||||
"asset"."updateId" < $1
|
||||
and "asset"."updateId" > $2
|
||||
"asset"."updateId" < $2
|
||||
and "asset"."updateId" > $3
|
||||
and "ownerId" in (
|
||||
select
|
||||
"sharedById"
|
||||
from
|
||||
"partner"
|
||||
where
|
||||
"sharedWithId" = $3
|
||||
"sharedWithId" = $4
|
||||
)
|
||||
order by
|
||||
"asset"."updateId" asc
|
||||
|
|
|
|||
|
|
@ -595,7 +595,8 @@ class PartnerAssetsSync extends BaseSync {
|
|||
@GenerateSql({ params: [dummyBackfillOptions, DummyValue.UUID], stream: true })
|
||||
getBackfill(options: SyncBackfillOptions, partnerId: string) {
|
||||
return this.backfillQuery('asset', options)
|
||||
.select(columns.syncAsset)
|
||||
.select(columns.syncPartnerAsset)
|
||||
.select(sql.val(false).as('isFavorite'))
|
||||
.select('asset.updateId')
|
||||
.where('ownerId', '=', partnerId)
|
||||
.stream();
|
||||
|
|
@ -614,7 +615,8 @@ class PartnerAssetsSync extends BaseSync {
|
|||
@GenerateSql({ params: [dummyQueryOptions], stream: true })
|
||||
getUpserts(options: SyncQueryOptions) {
|
||||
return this.upsertQuery('asset', options)
|
||||
.select(columns.syncAsset)
|
||||
.select(columns.syncPartnerAsset)
|
||||
.select(sql.val(false).as('isFavorite'))
|
||||
.select('asset.updateId')
|
||||
.where('ownerId', 'in', (eb) =>
|
||||
eb.selectFrom('partner').select(['sharedById']).where('sharedWithId', '=', options.userId),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
import { Kysely, sql } from 'kysely';
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
// isFavorite was incorrectly included in partner asset sync on server <=2.X.X
|
||||
await sql`DELETE FROM session_sync_checkpoint WHERE type in ('PartnerAssetV1', 'PartnerAssetBackfillV1')`.execute(db);
|
||||
}
|
||||
|
||||
export async function down(): Promise<void> {
|
||||
// Not implemented
|
||||
}
|
||||
Loading…
Reference in New Issue