This commit is contained in:
2025-07-03 15:36:30 -03:00
parent ce1c1b367e
commit 208c43f398
18 changed files with 261 additions and 78 deletions

View File

@@ -46,15 +46,24 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
with order_layer.transact_writer() as transact:
transact.update(
key=KeyPair(new_image['id'], '0'),
update_expr='SET metadata__tenant_id = :tenant_id, \
metadata__related_ids = :related_ids, \
update_date = :update_date',
update_expr='SET tenant = :tenant_id, \
updated_at = :updated_at',
expr_attr_values={
':tenant_id': ids['org_id'],
':related_ids': set(ids.values()),
':update_date': now_,
':updated_at': now_,
},
)
transact.update(
key=KeyPair(new_image['id'], 'author'),
update_expr='SET user_id = :user_id, updated_at = :updated_at',
expr_attr_values={
':user_id': ids['user_id'],
':updated_at': now_,
},
)
# Post-migration: remove the following line
transact.put(
item={
'id': new_image['id'],
@@ -64,15 +73,4 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
}
)
for k, v in ids.items():
kind = k.removesuffix('_id')
transact.put(
item={
'id': new_image['id'],
'sk': f'related_ids#{kind}', # e.g. related_ids#user
'create_date': now_,
k: v,
}
)
return True