feat: trigger step library sync on tree publish and deactivate on delete
- Call sync_steps_from_tree in update_tree whenever the tree is published
(status transitions to 'published' or is already published and structure changes)
- Call deactivate_synced_steps_for_tree in delete_tree before db.commit()
so the FK SET NULL does not nullify source_tree_id before the WHERE clause runs
- Fix ::jsonb cast syntax in step_sync.py (asyncpg rejects :: operator in text()
queries; replaced with CAST(:content AS jsonb))
- Add UniqueConstraint('source_tree_id','source_node_id') to StepLibrary model
so Base.metadata.create_all (used by tests) creates the constraint that the
ON CONFLICT clause in sync_steps_from_tree depends on
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -136,7 +136,7 @@ async def sync_steps_from_tree(
|
||||
helpful_yes, helpful_no, is_featured, is_verified,
|
||||
created_at, updated_at
|
||||
) VALUES (
|
||||
gen_random_uuid(), :title, :step_type, :content::jsonb,
|
||||
gen_random_uuid(), :title, :step_type, CAST(:content AS jsonb),
|
||||
:created_by, :account_id, :visibility, true,
|
||||
:source_tree_id, :source_node_id, :last_synced_at,
|
||||
'{}', true,
|
||||
|
||||
Reference in New Issue
Block a user