Skip to content

Commit

Permalink
feat(domain): allow duplicated domain names
Browse files Browse the repository at this point in the history
> fix #432
> I wanted to create a protodomaine : www.zalando.fr/sneakers
> but since www.zalando.fr already exists, Easyadmin blocks me.
  • Loading branch information
lutangar committed Sep 6, 2021
1 parent a7b9638 commit a283038
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
25 changes: 25 additions & 0 deletions migrations/Version20210902124326.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace Application\Migrations;

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

final class Version20210902124326 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('DROP INDEX UNIQ_DOMAIN_NAME ON domain_name');
}

public function down(Schema $schema): void
{
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('CREATE UNIQUE INDEX UNIQ_DOMAIN_NAME ON domain_name (name)');
}
}
10 changes: 10 additions & 0 deletions src/DataFixtures/DomainFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ public function load(ObjectManager $manager): void
$manager->persist($yahoo);
$this->addReference('yahoo_domain', $yahoo);

$yahooFr = new DomainName('fr.yahoo.com');
$yahooFr->setPath('/');
$manager->persist($yahooFr);
$this->addReference('com_yahoo_fr', $yahooFr);

$yahooFrSante = new DomainName('fr.yahoo.com');
$yahooFrSante->setPath('/topics/sante-yahoo-france/');
$manager->persist($yahooFrSante);
$this->addReference('com_yahoo_fr_sante', $yahooFrSante);

$searchEnginesSet = new DomainsSet('Search Engines');
$searchEnginesSet->addDomain($google);
$searchEnginesSet->addDomain($bing);
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/DomainName.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DomainName
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=false, unique=true)
* @ORM\Column(name="name", type="string", length=255, nullable=false, unique=false)
* @Assert\Regex("/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/")
*/
private $name;
Expand Down

0 comments on commit a283038

Please sign in to comment.