Tranche 1 of LST-65 (ProjectManagement module migration). Decouples the TimeTracking module from the core-business entities before they move, with no entity relocation yet — keeps the diff minimal and the risk isolated. - New read contracts in Shared/Domain/Contract (minimal surface, aligned on the entities' real nullable signatures): ProjectInterface (id/code/name), TaskInterface (id/number/title), TaskTagInterface (id/label/color), ClientInterface (id/name). - Project/Task/TaskTag/Client implement their contract (entities stay in src/Entity for now). Project.client typed as ClientInterface. - TimeEntry (TimeTracking) now references ProjectInterface/TaskInterface/ TaskTagInterface instead of the concrete entities; repository + DQL untouched in behaviour. - resolve_target_entities maps the 4 contracts to the legacy entities (will be repointed to the module in tranche 2). - Adds the migration plan doc. 159 tests green, mapping valid, cs-fixer clean.
9.7 KiB
LST-65 (2.2) — Module ProjectManagement : plan de migration
Migration strangler du cœur métier Projets/Tâches vers
src/Module/ProjectManagement/. Additive, sans régression API. Exécution en 4 tranches incrémentalement vertes (chaque tranche compile +phpunitvert + commit ; aucun état cassé committé).
Branche : integration/modular-monolith-0.1-1.3 (empilement phase 2).
Vérif container : docker exec -u www-data php-lesstime-fpm php bin/console cache:clear
Tests : docker exec -u www-data php-lesstime-fpm php vendor/bin/phpunit (baseline = 159 verts).
Style : make php-cs-fixer-allow-risky. PHP declare(strict_types=1). SQL colonnes minuscules.
Périmètre (10 entités + écosystème)
Entités : Project, Task, Workflow, TaskStatus, TaskGroup, TaskEffort, TaskPriority, TaskTag, TaskRecurrence, TaskDocument. Enums : StatusCategory, RecurrenceType. Repos (9), State (7), MCP (38), Controller (1), Services (2 : CalDavService, RecurrenceCalculator), Listeners (3), ApiResource (SwitchWorkflowOutput), fixtures, tests.
Décisions d'architecture (figées)
- Contrats inter-modules uniquement (
src/Shared/Domain/Contract/), surface minimale :ProjectInterface:getId(): ?int,getCode(): ?string,getName(): ?stringTaskInterface:getId(): ?int,getNumber(): ?int,getTitle(): ?stringTaskTagInterface:getId(): ?int,getLabel(): ?string,getColor(): ?stringClientInterface:getId(): ?int,getName(): ?string- PAS de WorkflowInterface (Workflow est intra-module PM).
- Consommateur contractuel : seul le module TimeTracking (
TimeEntry) bascule Project/Task/TaskTag → interfaces. Project (PM) bascule client →ClientInterface. - Legacy non modularisé (Gitea/BookStack/Mail :
src/Controller/Mail/*,src/State/Gitea*,src/State/BookStack*,src/Service/GiteaApiService.php,src/ApiResource/BookStack*,src/Entity/TaskMailLink.php,src/Entity/TaskBookStackLink.php), Serializer MCP partagé (src/Mcp/Tool/Serializer.php), fixtures, tests : bascule du FQCN concretApp\Entity\X→App\Module\ProjectManagement\Domain\Entity\X. Couplage transitoire legacy→module, nettoyé en 2.4/2.5/2.6. - Repos : pattern Core/TimeTracking — interface
Domain/Repository/XxxRepositoryInterface+Infrastructure/Doctrine/DoctrineXxxRepository extends ServiceEntityRepository implements …+ bindingservices.yaml. Conserver les méthodes métier (findMaxNumberByProjectForUpdate,findFirstNonFinal,findDefault). - Services CalDavService + RecurrenceCalculator →
Infrastructure/du module (dépendance résiduelle ZimbraConfiguration legacy tolérée jusqu'à 2.6). - Serializer.php reste à
src/Mcp/Tool/(helper multi-domaines), import concret PM. - Timestampable additif : sur Task et Project uniquement (agrégats), pas les référentiels. Migration additive (4 colonnes nullable + FK SET NULL + COMMENT).
- Table inchangée (naming strategy → mêmes tables). Aucune migration destructive.
- resolve_target_entities final :
UserInterface -> App\Module\Core\Domain\Entity\User (existant) ProjectInterface -> App\Module\ProjectManagement\Domain\Entity\Project TaskInterface -> App\Module\ProjectManagement\Domain\Entity\Task TaskTagInterface -> App\Module\ProjectManagement\Domain\Entity\TaskTag ClientInterface -> App\Entity\Client (Client legacy jusqu'à 2.4)
Tranche 1 — Découplage EN PLACE (entités non déplacées)
But : créer les contrats et basculer les consommateurs inter-modules, sans déplacer les entités → diff minimal, isole le risque architectural.
- Créer les 4 interfaces dans
src/Shared/Domain/Contract/(signatures ci-dessus). src/Entity/Project.phpimplements ProjectInterface;Task.phpimplements TaskInterface;TaskTag.phpimplements TaskTagInterface;Client.phpimplements ClientInterface. (Méthodes déjà présentes — justeimplements+use.)Project.php:client→ type?ClientInterface(targetEntity: ClientInterface::class, import, getter/setter).src/Module/TimeTracking/Domain/Entity/TimeEntry.php:project→?ProjectInterface,task→?TaskInterface,tags→Collection<TaskTagInterface>(targetEntity= interfaces, imports, getters/setters/addTag/removeTag). MAJTimeEntryRepositoryInterface/DoctrineTimeEntryRepository/ActiveTimeEntryProvider/TimeEntryExportControllersi typage Project/Task.config/packages/doctrine.yaml: ajouter les 4 lignesresolve_target_entities(cibles =App\Entity\Project/Task/TaskTag+App\Entity\Client— encore legacy à ce stade).- Vérif :
cache:clearOK +phpunitvert. Commitrefactor(project-management) : introduce Project/Task/TaskTag/Client contracts, decouple TimeTracking.
Tranche 2 — Move mécanique vers le module
But : déplacer entités + écosystème, bascule namespaces, sans changement de comportement.
git mventités →src/Module/ProjectManagement/Domain/Entity/(namespaceApp\Module\ProjectManagement\Domain\Entity). Relations intra-module = concret ; client=ClientInterface; assignee/collaborators/uploadedBy=UserInterface(inchangé).repositoryClass→DoctrineXxxRepository::class.git mvenums →src/Module/ProjectManagement/Domain/Enum/(namespace adapté).- Repos →
Infrastructure/Doctrine/DoctrineXxxRepository.php+ interfacesDomain/Repository/XxxRepositoryInterface.php(méthodes métier dans l'interface). Bindingsservices.yaml(9). - State (7), MCP (38), Controller (1), Services (2), Listeners (3), ApiResource SwitchWorkflowOutput → sous-dossiers
Infrastructure/…du module, namespaces adaptés, injecter les interfaces de repo.services.yaml: repointerApp\State\TaskDocumentProcessor,App\Controller\TaskDocumentDownloadController,App\Mcp\Tool\Task\AddTaskDocumentTool,App\Mcp\Tool\Task\UpdateTaskDocumentTool,App\EventListener\TaskDocumentListenervers les nouveaux FQCN (garder$uploadDir+ tagdoctrine.orm.entity_listener). resolve_target_entities: repointer ProjectInterface/TaskInterface/TaskTagInterface vers les FQCN module. (ClientInterface resteApp\Entity\Client.)- Swap FQCN concret legacy : remplacer
App\Entity\{Task,Project,Workflow,TaskStatus,TaskGroup,TaskEffort,TaskPriority,TaskTag,TaskRecurrence,TaskDocument}→App\Module\ProjectManagement\Domain\Entity\…etApp\Enum\{StatusCategory,RecurrenceType}→App\Module\ProjectManagement\Domain\Enum\…etApp\Repository\Xxx→ interfaces/Doctrine, dans : Serializer.php, Controller/Mail/, State/Gitea, State/BookStack*, ApiResource/BookStack*, Service/GiteaApiService.php, Entity/TaskMailLink.php, Entity/TaskBookStackLink.php, DataFixtures/AppFixtures.php, tests/*. (NE PAS toucherApp\Entity\Client.) config/modules.php: ajouterProjectManagementModule(idproject-management, labelProjets & Tâches, isRequired false, permissionsproject-management.projects.view/manage,project-management.tasks.view/manage— non recâblées, additif).config/packages/doctrine.yaml: mappingProjectManagement(dirsrc/Module/ProjectManagement/Domain/Entity).config/sidebar.php:'module' => 'project-management'sur itemsmy-tasksetprojects.- Vérif :
cache:clearOK +doctrine:schema:validatemapping OK +phpunitvert + cs-fixer. Commitfeat(project-management) : migrate core Projects/Tasks domain into module (back).
Tranche 3 — Timestampable additif (Task + Project)
- Ajouter
TimestampableBlamableTrait+ interfaces àTasketProject. - Migration additive manuscrite :
created_at/updated_at(TIMESTAMP(0) null),created_by/updated_by(INT null, FK"user"ON DELETE SET NULL) + index + COMMENT, surtasketproject.down()= DROP des ajouts. - Champs hors groupes API existants (le trait porte ses propres groupes).
- Vérif :
migrations:migrate -n(dev+test) +phpunitvert. Commitfeat(project-management) : add timestampable/blamable to Task and Project (additive).
Tranche 4 — Front layer project-management
git mvversfrontend/modules/project-management/: pages (my-tasks, projects/index, projects/[id]/{index,groups,archives}), components/{project,task}/, services (projects, tasks, workflows, task-statuses, task-priorities, task-efforts, task-tags, task-groups, task-documents, task-recurrences) + services/dto/ correspondants.nuxt.config.ts=export default defineNuxtConfig({}).- Réécrire imports explicites
~/services/<x>+~/services/dto/<x>→~/modules/project-management/...dans : les fichiers déplacés,components/admin/{AdminEffortTab,AdminPriorityTab,AdminTagTab,AdminWorkflowTab,WorkflowDrawer}.vue,components/mail/{MailCreateTaskModal,MailLinkTaskModal}.vue,pages/index.vue,pages/mail.vue,app/layouts/default.vue, etfrontend/modules/time-tracking/(dto/time-entry, stores/timer, pages/time-tracking, components/TimeEntryDrawer importent project/task/task-tag dto).clients.tsreste racine. - Préserver routes
/my-tasks,/projects,/projects/:id,/projects/:id/groups,/projects/:id/archives. i18n global inchangé. - Vérif :
cd frontend && npx nuxt buildOK + routes présentes. Commitfeat(project-management) : extract Projects/Tasks front into Nuxt module layer.
Critères d'acceptation (ticket)
- Cœur Projets/Tâches en module sans régression API (opérations/securities/uriTemplates conservés).
- Aucun import direct inter-modules établis (contrats) — legacy en transit toléré.
make testvert, aucune migration destructive.- Toggle module project-management (sidebar + routes) prouvé.