diff --git a/src/Entity/Gebruiker.php b/src/Entity/Gebruiker.php index 3a25b41f..2044904e 100644 --- a/src/Entity/Gebruiker.php +++ b/src/Entity/Gebruiker.php @@ -15,7 +15,8 @@ * @ORM\Entity(repositoryClass="GemeenteAmsterdam\FixxxSchuldhulp\Repository\GebruikerRepository") * @ORM\Table( * uniqueConstraints={ - * @ORM\UniqueConstraint(name="uq_username", columns={"username"}) + * @ORM\UniqueConstraint(name="uq_username", columns={"username"}), + * @ORM\UniqueConstraint(name="uq_email", columns={"email"}) * } * ) */ diff --git a/src/Migrations/Version20200818095526.php b/src/Migrations/Version20200818095526.php new file mode 100644 index 00000000..de588c34 --- /dev/null +++ b/src/Migrations/Version20200818095526.php @@ -0,0 +1,29 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('CREATE UNIQUE INDEX uq_email ON gebruiker (email)'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('CREATE SCHEMA public'); + $this->addSql('DROP INDEX uq_email'); + } +}