An appointment could say which services it was for but not which resource performed them, so a booking on laser #2 was indistinguishable from one on laser #1. Both columns are nullable: the appointments that already exist have no resource and the migration must not break them. resource_id is not a duplicate of resource_occupancy. Occupancy records what was held and when — including rooms and devices held for a single segment. This column records what the appointment is *for*, which is what the panel lists and what the patient chose. The option is kept separately from service_item because duration and price resolve from the resource+service+option triple; without knowing the option, the stored number cannot be explained later. Tests: the resource and option survive a round-trip, stored minutes come from the resolver rather than the service default (15 where the service says 30), raising the tariff afterwards leaves the earlier snapshot at 8M, and an appointment with no resource still serialises with nulls instead of failing. Suite 1290 green, phpstan at its 14-error baseline. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
40 lines
1.7 KiB
PHP
40 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
/**
|
|
* Auto-generated Migration: Please modify to your needs!
|
|
*/
|
|
final class Version20260801181433 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return '';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
// this up() migration is auto-generated, please modify it to your needs
|
|
$this->addSql('ALTER TABLE appointments ADD resource_id INT DEFAULT NULL, ADD service_option_item_id INT DEFAULT NULL');
|
|
$this->addSql('ALTER TABLE appointments ADD CONSTRAINT FK_6A41727A89329D25 FOREIGN KEY (resource_id) REFERENCES clinic_resources (id) ON DELETE SET NULL');
|
|
$this->addSql('ALTER TABLE appointments ADD CONSTRAINT FK_6A41727A9FD189D FOREIGN KEY (service_option_item_id) REFERENCES service_items (id) ON DELETE SET NULL');
|
|
$this->addSql('CREATE INDEX IDX_6A41727A89329D25 ON appointments (resource_id)');
|
|
$this->addSql('CREATE INDEX IDX_6A41727A9FD189D ON appointments (service_option_item_id)');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
// this down() migration is auto-generated, please modify it to your needs
|
|
$this->addSql('ALTER TABLE appointments DROP FOREIGN KEY FK_6A41727A89329D25');
|
|
$this->addSql('ALTER TABLE appointments DROP FOREIGN KEY FK_6A41727A9FD189D');
|
|
$this->addSql('DROP INDEX IDX_6A41727A89329D25 ON appointments');
|
|
$this->addSql('DROP INDEX IDX_6A41727A9FD189D ON appointments');
|
|
$this->addSql('ALTER TABLE appointments DROP resource_id, DROP service_option_item_id');
|
|
}
|
|
}
|