feat(projects): tenant-scoped project_types lookup table + CRUD #240
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/PMS-322-project-type-lookup"
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?
Summary
Replaces the hardcoded
projects.project_typeenum (VARCHAR(20) CHECK (project_type IN ('client','internal'))) with a tenant-scopedproject_typeslookup table + full CRUD, so the MAPPS Settings hub (MAPPS-169) can manage project types per tenant. Mirrors thetask_statusespattern in the same module. Blocks the MAPPS project-type editor (MAPPS-173).Migration 048
project_types(id, tenant_id, name, is_default, is_active, sort_order, is_system), with its own RLStenant_isolationpolicy andupdated_attrigger attached explicitly (the 038 RLS sweep and 024/043 trigger sweeps already ran, so a new table is not covered by them).client/internalas system defaults (is_system = true,clientdefault) for every existing tenant.projects.project_type_id UUID REFERENCES project_types(id), backfills it from the legacy string (every value is seeded, so no orphans / no NULLs), indexes it, then drops the CHECK.project_typestring column for one release (create/read still write/return it). New forward migration per the 043 precedent (007's checksum is locked).Behavior
/api/v1/project-types, admin-gated (RequireAdmin), reads onRequireProjects.is_system = true) cannot be deleted via the API (409).create_projectresolvesproject_type_idfrom the legacy string, so new rows are linked too;ProjectResponsenow carriesproject_type_id.copy_default_configgains aproject_typescopy block (carryingis_system) so future tenants inherit the seeds.Audit (AC)
Grepped the server for code branching on the literal
client/internalvalues. None exists - the string is only defaulted (CreateProjectRequest), stored, and echoed back, so the values moved to data with zero behavioral change. The otherinternalmatches are unrelated (knowledge_basevisibility, ticket note type).Tests
tests/projects.rs: seeded system defaults present, custom-type CRUD + re-delete 404, project create resolvesproject_type_id, system-row delete 409, referenced-type delete 409, new-default-clears-prior, technician mutation 403. The four pre-existing project tests still pass (added column did not disturb create/read).tenants+tenant_isolationsuites pass (cover thecopy_default_configchange).clippy --tests -D warnings+fmtclean.Follow-up (not this PR)
Dropping the legacy
projects.project_typestring column once clients readproject_type_idis a separate release.#PMS-322