Skip to content

Document to SourceFile link + cascade semantics #46

@AymanL

Description

@AymanL

Parent PRD

#33

What to build

Add a nullable FK from Document to SourceFile to make the metadata-only and file-attached states explicit, with the correct cascade semantics (see PRD §Implementation Decisions — Cascade deletion). No pipeline rewiring; models, migrations, and minimal admin only.

Acceptance criteria

  • Document has a nullable source_file FK to SourceFile (on_delete=CASCADE so that deleting a SourceFile deletes the linked Document).
  • A Document with source_file=None is valid (metadata-only state).
  • A Document can be linked to at most one SourceFile.
  • Migration is generated and applies cleanly.
  • Tests: metadata-only Document (no SourceFile) is created successfully; deleting a SourceFile cascades and removes the linked Document; a Document cannot be linked to more than one SourceFile.

Blocked by

User stories addressed

Reference by number from the parent PRD:

  • User story 4 (SourceFile represents only the stored file)
  • User story 5 (Document links to at most one SourceFile)
  • User story 6 (deleting SourceFile cascades to Document)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions