-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dependency/dependant tracking (#426)
* Basic dependency/dependant tracking * Add other link types to test a design * Allow searching for dependants * Slightly nicer looking package list * Move dependant link to overview & update/fix tests * Fix doctrine schema validation * Add missing foreign key * Rename index to what doctrine suggests * Test each of the link types * Improve test coverage
- Loading branch information
Showing
19 changed files
with
514 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Buddy\Repman\Entity\Organization\Package; | ||
|
||
use Buddy\Repman\Entity\Organization; | ||
use Buddy\Repman\Entity\Organization\Package; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Ramsey\Uuid\UuidInterface; | ||
|
||
/** | ||
* @ORM\Entity | ||
* @ORM\Table( | ||
* name="organization_package_link", | ||
* indexes={ | ||
* @ORM\Index(name="link_package_id_idx", columns={"package_id"}), | ||
* @ORM\Index(name="link_target_idx", columns={"target"}), | ||
* } | ||
* ) | ||
*/ | ||
class Link | ||
{ | ||
/** | ||
* @ORM\Id() | ||
* @ORM\Column(type="uuid") | ||
*/ | ||
private UuidInterface $id; | ||
|
||
/** | ||
* @ORM\ManyToOne(targetEntity="Buddy\Repman\Entity\Organization") | ||
* @ORM\JoinColumn(nullable=false) | ||
*/ | ||
private Organization $organization; | ||
|
||
/** | ||
* @ORM\ManyToOne(targetEntity="Buddy\Repman\Entity\Organization\Package", inversedBy="links") | ||
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE") | ||
*/ | ||
private Package $package; | ||
|
||
/** | ||
* @ORM\Column(type="string") | ||
*/ | ||
private string $type; | ||
|
||
/** | ||
* @ORM\Column(type="string") | ||
*/ | ||
private string $target; | ||
|
||
/** | ||
* @ORM\Column(name="`constraint`",type="string") | ||
*/ | ||
private string $constraint; | ||
|
||
private ?string $packageId; | ||
private ?string $targetPackageId; | ||
|
||
public function __construct( | ||
UuidInterface $id, | ||
string $type, | ||
string $target, | ||
string $constraint, | ||
?string $packageId = null, | ||
?string $targetPackageId = null | ||
) { | ||
$this->id = $id; | ||
$this->type = $type; | ||
$this->target = $target; | ||
$this->constraint = $constraint; | ||
$this->packageId = $packageId; | ||
$this->targetPackageId = $targetPackageId; | ||
} | ||
|
||
public function type(): string | ||
{ | ||
return $this->type; | ||
} | ||
|
||
public function target(): string | ||
{ | ||
return $this->target; | ||
} | ||
|
||
public function constraint(): string | ||
{ | ||
return $this->constraint; | ||
} | ||
|
||
public function targetPackageId(): ?string | ||
{ | ||
return $this->targetPackageId; | ||
} | ||
|
||
public function setOrganization(Organization $organization): void | ||
{ | ||
if (isset($this->organization)) { | ||
throw new \RuntimeException('You can not change link organization'); | ||
} | ||
$this->organization = $organization; | ||
} | ||
|
||
public function setPackage(Package $package): void | ||
{ | ||
if (isset($this->package)) { | ||
throw new \RuntimeException('You can not change link package'); | ||
} | ||
$this->package = $package; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Buddy\Repman\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20210309201702 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Add package links'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
|
||
$this->addSql('CREATE TABLE organization_package_link (id UUID NOT NULL, organization_id UUID NOT NULL, package_id UUID NOT NULL, target VARCHAR(255) NOT NULL, "constraint" VARCHAR(255) NOT NULL, type VARCHAR (255) NOT NULL, PRIMARY KEY(id))'); | ||
$this->addSql('CREATE INDEX link_package_id_idx ON organization_package_link (package_id)'); | ||
$this->addSql('CREATE INDEX IDX_4A06082932C8A3DE ON organization_package_link (organization_id)'); | ||
$this->addSql('CREATE INDEX link_target_idx ON organization_package_link (target)'); | ||
$this->addSql('COMMENT ON COLUMN organization_package_link.id IS \'(DC2Type:uuid)\''); | ||
$this->addSql('COMMENT ON COLUMN organization_package_link.package_id IS \'(DC2Type:uuid)\''); | ||
$this->addSql('COMMENT ON COLUMN organization_package_link.organization_id IS \'(DC2Type:uuid)\''); | ||
$this->addSql('ALTER TABLE organization_package_link ADD CONSTRAINT FK_CAKE4LIFE FOREIGN KEY (package_id) REFERENCES organization_package (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); | ||
$this->addSql('ALTER TABLE organization_package_link ADD CONSTRAINT FK_4A06082932C8A3DE FOREIGN KEY (organization_id) REFERENCES organization (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
|
||
$this->addSql('DROP TABLE organization_package_link'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.