306cfd34cd
LST-66 (2.3) backend. Behaviour-preserving move of the absences domain into
src/Module/Absence/. API operations, securities, routes and the 10 MCP tool
names are unchanged.
- 3 entities + 3 enums moved to Domain/{Entity,Enum}; user relations stay on
UserInterface. 3 repositories split into Domain/Repository interfaces +
Doctrine impls (bound in services.yaml); find() kept off interfaces
(findById instead).
- Pure services (AbsenceDayCalculator, PublicHolidayProvider) -> Domain/Service;
AbsenceBalanceService -> Application/Service; State (5), controllers (5),
10 MCP tools and AccrueLeaveCommand -> Infrastructure/.
- New LeaveProfileInterface contract (Shared) exposes the HR getters used by
AbsenceBalanceService/AccrueLeaveCommand; User implements it -> Absence no
longer imports the concrete Core User. MCP tools/command inject
UserRepositoryInterface (findById) instead of the concrete repository.
- Timestampable/Blamable added to AbsenceBalance and AbsencePolicy (additive
migration: created_at/updated_at + created_by/updated_by FK ON DELETE SET
NULL + COMMENT). AbsenceRequest untouched (already has createdAt/reviewedAt).
- AbsenceModule registered (id absence, 4 RBAC perms, not re-wired); doctrine
mapping added; team-absences sidebar item gated by the module.
161 tests green, mapping valid, no API route regression, cs-fixer clean.
82 lines
5.1 KiB
PHP
82 lines
5.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
/**
|
|
* Absence module: add Timestampable/Blamable columns to absence_balance and
|
|
* absence_policy.
|
|
*
|
|
* AbsenceBalance and AbsencePolicy adopt TimestampableBlamableTrait.
|
|
* AbsenceRequest is intentionally untouched (it already carries createdAt /
|
|
* reviewedAt). This migration is purely additive — nullable columns + nullable
|
|
* FK to "user" with ON DELETE SET NULL. No DROP/ALTER on existing data. Columns
|
|
* are lowercase snake_case. Hand-written to guarantee zero destructive
|
|
* instruction.
|
|
*/
|
|
final class Version20260620170000 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Absence: add timestampable/blamable columns to absence_balance and absence_policy (additive)';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
// absence_balance
|
|
$this->addSql('ALTER TABLE absence_balance ADD created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
|
|
$this->addSql('ALTER TABLE absence_balance ADD updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
|
|
$this->addSql('ALTER TABLE absence_balance ADD created_by INT DEFAULT NULL');
|
|
$this->addSql('ALTER TABLE absence_balance ADD updated_by INT DEFAULT NULL');
|
|
$this->addSql('ALTER TABLE absence_balance ADD CONSTRAINT FK_65723A76DE12AB56 FOREIGN KEY (created_by) REFERENCES "user" (id) ON DELETE SET NULL NOT DEFERRABLE');
|
|
$this->addSql('ALTER TABLE absence_balance ADD CONSTRAINT FK_65723A7616FE72E1 FOREIGN KEY (updated_by) REFERENCES "user" (id) ON DELETE SET NULL NOT DEFERRABLE');
|
|
$this->addSql('CREATE INDEX IDX_65723A76DE12AB56 ON absence_balance (created_by)');
|
|
$this->addSql('CREATE INDEX IDX_65723A7616FE72E1 ON absence_balance (updated_by)');
|
|
$this->addSql("COMMENT ON COLUMN absence_balance.created_at IS 'Creation timestamp (Timestampable, set on prePersist)'");
|
|
$this->addSql("COMMENT ON COLUMN absence_balance.updated_at IS 'Last update timestamp (Timestampable, set on prePersist/preUpdate)'");
|
|
$this->addSql("COMMENT ON COLUMN absence_balance.created_by IS 'User who created the entry (Blamable, FK user.id, SET NULL on delete)'");
|
|
$this->addSql("COMMENT ON COLUMN absence_balance.updated_by IS 'User who last updated the entry (Blamable, FK user.id, SET NULL on delete)'");
|
|
|
|
// absence_policy
|
|
$this->addSql('ALTER TABLE absence_policy ADD created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
|
|
$this->addSql('ALTER TABLE absence_policy ADD updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
|
|
$this->addSql('ALTER TABLE absence_policy ADD created_by INT DEFAULT NULL');
|
|
$this->addSql('ALTER TABLE absence_policy ADD updated_by INT DEFAULT NULL');
|
|
$this->addSql('ALTER TABLE absence_policy ADD CONSTRAINT FK_7A780B65DE12AB56 FOREIGN KEY (created_by) REFERENCES "user" (id) ON DELETE SET NULL NOT DEFERRABLE');
|
|
$this->addSql('ALTER TABLE absence_policy ADD CONSTRAINT FK_7A780B6516FE72E1 FOREIGN KEY (updated_by) REFERENCES "user" (id) ON DELETE SET NULL NOT DEFERRABLE');
|
|
$this->addSql('CREATE INDEX IDX_7A780B65DE12AB56 ON absence_policy (created_by)');
|
|
$this->addSql('CREATE INDEX IDX_7A780B6516FE72E1 ON absence_policy (updated_by)');
|
|
$this->addSql("COMMENT ON COLUMN absence_policy.created_at IS 'Creation timestamp (Timestampable, set on prePersist)'");
|
|
$this->addSql("COMMENT ON COLUMN absence_policy.updated_at IS 'Last update timestamp (Timestampable, set on prePersist/preUpdate)'");
|
|
$this->addSql("COMMENT ON COLUMN absence_policy.created_by IS 'User who created the entry (Blamable, FK user.id, SET NULL on delete)'");
|
|
$this->addSql("COMMENT ON COLUMN absence_policy.updated_by IS 'User who last updated the entry (Blamable, FK user.id, SET NULL on delete)'");
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
// absence_balance
|
|
$this->addSql('ALTER TABLE absence_balance DROP CONSTRAINT FK_65723A76DE12AB56');
|
|
$this->addSql('ALTER TABLE absence_balance DROP CONSTRAINT FK_65723A7616FE72E1');
|
|
$this->addSql('DROP INDEX IDX_65723A76DE12AB56');
|
|
$this->addSql('DROP INDEX IDX_65723A7616FE72E1');
|
|
$this->addSql('ALTER TABLE absence_balance DROP created_at');
|
|
$this->addSql('ALTER TABLE absence_balance DROP updated_at');
|
|
$this->addSql('ALTER TABLE absence_balance DROP created_by');
|
|
$this->addSql('ALTER TABLE absence_balance DROP updated_by');
|
|
|
|
// absence_policy
|
|
$this->addSql('ALTER TABLE absence_policy DROP CONSTRAINT FK_7A780B65DE12AB56');
|
|
$this->addSql('ALTER TABLE absence_policy DROP CONSTRAINT FK_7A780B6516FE72E1');
|
|
$this->addSql('DROP INDEX IDX_7A780B65DE12AB56');
|
|
$this->addSql('DROP INDEX IDX_7A780B6516FE72E1');
|
|
$this->addSql('ALTER TABLE absence_policy DROP created_at');
|
|
$this->addSql('ALTER TABLE absence_policy DROP updated_at');
|
|
$this->addSql('ALTER TABLE absence_policy DROP created_by');
|
|
$this->addSql('ALTER TABLE absence_policy DROP updated_by');
|
|
}
|
|
}
|