Cascade template slug changes to referencing posts and tags #80
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Source: Audit section 2.11.
Spec:
specs/template.alliumrule CascadeSlugUpdate: when a template slug changes, update all referencing posts' template_slug and tags' post_template_slug.bDS2:
../bDS2/lib/bds/templates.excascade_template_slug_change(~line 488) updates posts.template_slug and tags.post_template_slug inside the update transaction (commit_update_transaction~line 229) and returns affected posts for side-effect sync.Current behaviour (RuDS):
crates/bds-core/src/engine/template.rsupdate_template(~line 61) changes the slug and leavesposts.template_slug/tags.post_template_slugpointing at the old slug — references dangle and posts silently fall back to default templates at render time.Task: On slug change in
update_template, inside a savepoint: update referencing posts and tags to the new slug (bump their updated_at), and consider whether published referencing posts need their frontmatter rewritten (templateSlug is written to post files — bDS2 syncs side effects for affected posts; checksync_template_update_side_effectsin templates.ex and mirror). Emit domain events for changed entities.Acceptance: Test: template referenced by a post + a tag, rename slug → both references updated, no dangling slug; published referencing post's file frontmatter matches DB.
Implemented in
e28d42d. Template slug updates now capture project-scoped referencing posts and tags and update the template plus both reference sets atomically in one savepoint, bumping affected timestamps. After commit, every published affected post file is rewritten with the new templateSlug, tags.json is regenerated, and typed Updated events are emitted for the template, posts, and tags. Desktop, TUI, and scripting callers now provide the real data directory. Added end-to-end coverage for DB references, published frontmatter, tags.json, events, and a trigger-induced whole-cascade rollback; template-file renaming remains isolated to #81. Updated README. Verified against bDS2 and CascadeSlugUpdate with Allium check/analyse, cargo fmt --check, cargo check --workspace, cargo machete --with-metadata, cargo build --workspace, focused tests, ORM-boundary validation, and cargo test --workspace (all passed; one intentional model-download test ignored).