Skip to content

feat!: Add Container.container_code field#545

Draft
kdmccormick wants to merge 4 commits intokdmccormick/keys-componentfrom
kdmccormick/keys-container
Draft

feat!: Add Container.container_code field#545
kdmccormick wants to merge 4 commits intokdmccormick/keys-componentfrom
kdmccormick/keys-container

Conversation

@kdmccormick
Copy link
Copy Markdown
Member

@kdmccormick kdmccormick commented Apr 15, 2026

Description

Adds a container_code field (code_field) and a learning_package FK to the Container model. Also adds a UniqueConstraint on (learning_package, container_code), which is stricter than Component's constraint (no type scoping -- container codes must be unique across all container types within a given LearningPackage).

For existing containers, container_code is backfilled from the entity key via a data migration. Future containers will have container_code set explicitly by the caller.

Backup/restore now writes container_code into the [entity.container] section (Verawood and later). Archives created in Ulmo (which have no container_code) fall back to using the entity key as the container_code on restore.

BREAKING CHANGE: create_container() and create_container_and_version() now require a container_code keyword argument. The same applies to create_unit_and_version(), create_subsection_and_version(), and create_section_and_version().

Part of: #322

Full series of PRs:

  1. feat!: Collection.key -> Collection.collection_code #542
  2. feat!: Component.local_key -> Component.component_code #544
  3. feat!: Add Container.container_code field #545
  4. feat!: Package and Entity keys are now opaque refs #546
  5. feat!: ComponentVersionMedia.key -> ComponentVersionMedia.path #547

Testing

TBC

AI disclosure

Claude helped me write this PR. See #322 for details.

learning_package_id: LearningPackage.ID,
key: str,
*,
container_code: str,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that this has key and container_code is just from how the PRs are split up right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep

kdmccormick and others added 3 commits April 16, 2026 13:20
Adds a container_code field (code_field) and a learning_package FK to the
Container model. Also adds a UniqueConstraint on (learning_package,
container_code), which is stricter than Component's constraint
(no type scoping -- container codes must be unique across all container
types within a given LearningPackage).

For existing containers, container_code is backfilled from the entity key
via a data migration. Future containers will have container_code set
explicitly by the caller.

Backup/restore now writes container_code into the [entity.container]
section (Verawood and later). Archives created in Ulmo (which have no
container_code) fall back to using the entity key as the container_code
on restore.

BREAKING CHANGE: create_container() and create_container_and_version()
now require a container_code keyword argument. The same applies to
create_unit_and_version(), create_subsection_and_version(), and
create_section_and_version().

Part of: #322

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…base

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@kdmccormick kdmccormick force-pushed the kdmccormick/keys-component branch from fbe4b4b to f4d32b8 Compare April 16, 2026 18:18
@kdmccormick kdmccormick force-pushed the kdmccormick/keys-container branch from 266d7f3 to 5283857 Compare April 16, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants