add validation to accompanying periods

This commit is contained in:
2021-11-12 12:07:31 +00:00
parent 39ab7057ce
commit c8135e0741
22 changed files with 337 additions and 88 deletions

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Validation added to accompanying period resources and accompanying period.
*/
final class Version20211020131133 extends AbstractMigration
{
public function getDescription(): string
{
return 'Validation added to accompanying period resources and accompanying period.';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE UNIQUE INDEX person_unique ON chill_person_accompanying_period_resource (person_id, accompanyingperiod_id) WHERE person_id IS NOT NULL');
$this->addSql('CREATE UNIQUE INDEX thirdparty_unique ON chill_person_accompanying_period_resource (thirdparty_id, accompanyingperiod_id) WHERE thirdparty_id IS NOT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('DROP INDEX person_unique');
$this->addSql('DROP INDEX thirdparty_unique');
}
}