Skip to content

set parent links before a new schema's name template - #272

Closed
mghent wants to merge 1 commit into
dynotx:mainfrom
involvedata:create-link-order
Closed

mghent wants to merge 1 commit into
dynotx:mainfrom
involvedata:create-link-order

Conversation

@mghent

@mghent mghent commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Closes #271.

Problem

When a revision creates a batch schema whose name template uses its parent's lot number, upgrade fails at the name template. Two things cause it:

  • Order. Operations sort by type, so a new schema's name template (110) and naming strategy (120) run before the field update that sets the link target (140).
  • parent_link. The link field is created without a target, so it can't be a parent link yet. The follow-up update set only type and entity_link, so the field never became a parent link.

Change

These changes apply only in the create branch of compare_entity_schemas:

  • The follow-up link update sets parent_link=True along with the target. The create leaves parent_link off.
  • The name template and template-based naming strategies run after field updates. CompareOperation gets an optional order that overrides op.order when sorting, and these two operations use UpdateEntitySchemaField.order + 1 and + 2.
  • The warehouse rename is its own UpdateEntitySchema and stays at the default order, because the later operations use the model's warehouse name.

Revisions for existing schemas are unchanged. Every operation they generate keeps order=None.

For Cell Line and Cell Line Batch, a new revision now runs:

  1. create Cell Line
  2. create Cell Line Batch
  3. point Parent Cell Line at Cell Line, with parent_link=True
  4. set the name template
  5. set the naming strategy

Testing

  • New test_compare_benchling_schemas_create_link_order covers a parent schema plus a batch with a parent-lot-number template and a custom warehouse name. It checks the operation order, that parent_link moves from the create to the link update, and that every field update runs before any new schema's template.
  • test_compare_benchling_schema_fields now also checks that operations for an existing schema keep the default order.
  • Live, on a tenant with six registries (with scope connection to one registry for multi-registry tenants #262 applied): one revision created a cell line and a cell line batch schema, with a parent link and a {parent}-{lot number} template. It applied cleanly, diff showed both schemas matching code, and downgrade archived both and restored the remote revision.

When a revision creates a schema whose name template uses a parent's lot
number, the template was set before the parent link existed, and the link
update left out parent_link. For newly created schemas:

- the follow-up link update sets parent_link with the target, and the
  create leaves it off
- the name template and template based naming strategies run after field
  updates, through an order override on CompareOperation
- the warehouse rename stays early and is its own step

Revisions for existing schemas keep the default order.

Closes dynotx#271.
@ndamania00

Copy link
Copy Markdown
Collaborator

Closing this PR, as I've merged in #276. Thanks for your help here!

@ndamania00 ndamania00 closed this Nov 11, 2026
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.

A new batch schema whose name uses its parent's lot number fails to create

2 participants