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>
9 lines
335 B
SQL
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;
|