Files
tenant-registry/migrations/0020_project_hierarchy.down.sql
T
Sharang ParnerkarandClaude Opus 5.5 c4b7686cc5
ci / shared (pull_request) Successful in 14s
ci / test (pull_request) Successful in 25m43s
ci / image (pull_request) Skipped
feat(projects): product hierarchy - family, product, component
A product project gets a level (family | product | component) and a
parent (migration 0020), so a machine with its robot arm, PLC, edge
server and Windows app, or a product family, can be modelled. Topics stay
flat; kind is unchanged and old clients get level "product" at the top.
The API checks the tree: allowed parents per level, same tenant, no
cycles, at most 4 levels, children still fitting after a level change.
The database keeps parents within the tenant and refuses to delete a
project with children (409 has_children). The list stays flat with
level and parent_id. A document's role follows the level of the project
it is linked to; no document schema change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 22:10:15 +02:00

9 lines
335 B
SQL

DROP INDEX IF EXISTS projects_parent_idx;
ALTER TABLE projects
DROP CONSTRAINT IF EXISTS projects_parent,
DROP CONSTRAINT IF EXISTS projects_tenant_id_key,
DROP CONSTRAINT IF EXISTS projects_not_own_parent,
DROP CONSTRAINT IF EXISTS projects_level,
DROP COLUMN IF EXISTS parent_id,
DROP COLUMN IF EXISTS level;