---
id: change/bcapps/10055
type: change
title: "#10055 Fix: migrating a document attachment deletes shared Tenant Media"
summary: Document attachment migration no longer deletes shared Tenant Media records, preventing silent loss of content when attachments are copied to posted documents.
tier: official
language: en
tags:
  - fix
  - main
  - bc30
  - codeunit da external storage impl.
system: development
review:
  state: reviewed
  by: opus
  at: "2026-10-08T02:08:31.700Z"
  flags: []
generated:
  at: "2026-10-08T01:26:53.141Z"
  pipeline: 0.2.0
  prompts:
    extract-change: 1
  input_hash: 473bb07683d69a4637515209367837b444b3a43e
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/pull/10055
    title: "microsoft/BCApps#10055: Fix: migrating a document attachment deletes shared Tenant Media"
    date: "2026-08-17"
    commit: 473bb07683d69a4637515209367837b444b3a43e
    t: null
    quote: Deleting that row on behalf of one attachment destroys the content of every attachment copied from it.
links:
  learn: []
  objects:
    - object/codeunit/8751
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes: []
number: 10055
repo: microsoft/BCApps
source_id: bcapps-prs
url: https://github.com/microsoft/BCApps/pull/10055
kind: pr
base_branch: main
major: "30"
merged_at: "2026-08-17T13:22:45Z"
author: Groenbech96
author_type: User
community_contribution: false
labels:
  - "AL: Apps (W1)"
  - "Build: scripts & configs"
  - "Team: Integrations"
change_class: code
change_kind: fix
behavior_change: true
breaking: false
files:
  count: 26
  additions: 198
  deletions: 7
  al: 1
apps:
  - External Storage - Document Attachments
objects_touched:
  - key: codeunit/8751
    page: codeunit/8751
    type: codeunit
    id: 8751
    name: DA External Storage Impl.
    app: External Storage - Document Attachments
    status: modified
objects_unjoined: []
obsoletions: []
backports: []
fixes_issues: []
work_items:
  - 646505
systems:
  - development
quote: Deleting that row on behalf of one attachment destroys the content of every attachment copied from it.
joined_against:
  major: "30"
  commit: ecbc028c25dbe83b61313bc566e6c1d41184bb1c
---

# #10055 Fix: migrating a document attachment deletes shared Tenant Media

> Document attachment migration no longer deletes shared Tenant Media records, preventing silent loss of content when attachments are copied to posted documents.

[Pull request](https://github.com/microsoft/BCApps/pull/10055) · merged into `main` (BC30) on 2026-08-17 by Groenbech96 · 26 files (+198 -7), 1 AL · fix · tier official · reviewed (checked by Opus)

## What changed

- Adds guard to prevent deletion of Tenant Media when other attachments reference the same media row
- Introduces three new unit tests verifying shared media protection and proper cleanup when attachment is the sole owner
- Fixes silent skipping of copied attachments during external storage migration that left records with missing content
- Protects internal Tenant Media deletion the same way external blob deletion was already protected
- Behaviour changes for users or extensions.

## AL objects touched

- [Codeunit 8751 "DA External Storage Impl."](../../objects/codeunit/8751.md), External Storage - Document Attachments: modified

## Context

- Work items: AB#646505
- Labels: AL: Apps (W1), Build: scripts & configs, Team: Integrations
- Systems: development
- From the description: "Deleting that row on behalf of one attachment destroys the content of every attachment copied from it."

Source: metadata of a merged pull request in microsoft/BCApps (bcapps): title, labels, changed paths and counts, with a summary in our words. No source text and no description beyond one short quote (D10, D61).
