Skip to content

Commit

Permalink
[membership] Add uniq constraint on member_number attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
petitalb committed Nov 16, 2022
1 parent 1b86325 commit 9fb56a1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
35 changes: 35 additions & 0 deletions app/DoctrineMigrations/Version20221116052856.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace Application\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20221116052856 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->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('CREATE UNIQUE INDEX UNIQ_86FFD285B2469D67 ON membership (member_number)');
}

public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('DROP INDEX UNIQ_86FFD285B2469D67 ON membership');
}
}
2 changes: 1 addition & 1 deletion src/AppBundle/Entity/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* Membership
*
* @ORM\Table(name="membership")
* @ORM\Table(name="membership", uniqueConstraints={@ORM\UniqueConstraint(columns={"member_number"})})
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity(repositoryClass="AppBundle\Repository\MembershipRepository")
* @UniqueEntity(fields={"member_number"}, message="Ce numéro de membre existe déjà")
Expand Down

0 comments on commit 9fb56a1

Please sign in to comment.