-
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.
Add support for showing all package versions. Refs #175.
- Loading branch information
1 parent
b456d03
commit 29e4703
Showing
23 changed files
with
651 additions
and
12 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
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,107 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Buddy\Repman\Entity\Organization\Package; | ||
|
||
use Buddy\Repman\Entity\Organization\Package; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Ramsey\Uuid\UuidInterface; | ||
|
||
/** | ||
* @ORM\Entity | ||
* @ORM\Table( | ||
* name="organization_package_version", | ||
* uniqueConstraints={@ORM\UniqueConstraint(name="package_version", columns={"package_id", "version"})}, | ||
* indexes={ | ||
* @ORM\Index(name="version_package_id_idx", columns={"package_id"}), | ||
* @ORM\Index(name="version_date_idx", columns={"date"}) | ||
* } | ||
* ) | ||
*/ | ||
class Version | ||
{ | ||
/** | ||
* @ORM\Id() | ||
* @ORM\Column(type="uuid") | ||
*/ | ||
private UuidInterface $id; | ||
|
||
/** | ||
* @ORM\ManyToOne(targetEntity="Buddy\Repman\Entity\Organization\Package", inversedBy="versions") | ||
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE") | ||
*/ | ||
private Package $package; | ||
|
||
/** | ||
* @ORM\Column(type="string") | ||
*/ | ||
private string $version; | ||
|
||
/** | ||
* @ORM\Column(type="string") | ||
*/ | ||
private string $reference; | ||
|
||
/** | ||
* @ORM\Column(type="integer") | ||
*/ | ||
private int $size; | ||
|
||
/** | ||
* @ORM\Column(type="datetime_immutable") | ||
*/ | ||
private \DateTimeImmutable $date; | ||
|
||
public function __construct( | ||
UuidInterface $id, | ||
string $version, | ||
string $reference, | ||
int $size, | ||
\DateTimeImmutable $date | ||
) { | ||
$this->id = $id; | ||
$this->version = $version; | ||
$this->reference = $reference; | ||
$this->size = $size; | ||
$this->date = $date; | ||
} | ||
|
||
public function id(): UuidInterface | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function version(): string | ||
{ | ||
return $this->version; | ||
} | ||
|
||
public function reference(): string | ||
{ | ||
return $this->reference; | ||
} | ||
|
||
public function size(): int | ||
{ | ||
return $this->size; | ||
} | ||
|
||
public function setReference(string $reference): void | ||
{ | ||
$this->reference = $reference; | ||
} | ||
|
||
public function setSize(int $size): void | ||
{ | ||
$this->size = $size; | ||
} | ||
|
||
public function setPackage(Package $package): void | ||
{ | ||
if (isset($this->package)) { | ||
throw new \RuntimeException('You can not change version 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,42 @@ | ||
<?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 Version20200706181929 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() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); | ||
|
||
$this->addSql('CREATE TABLE organization_package_version (id UUID NOT NULL, package_id UUID NOT NULL, version VARCHAR(255) NOT NULL, reference VARCHAR(255) NOT NULL, size INT NOT NULL, date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))'); | ||
$this->addSql('CREATE INDEX version_package_id_idx ON organization_package_version (package_id)'); | ||
$this->addSql('CREATE INDEX version_date_idx ON organization_package_version (date)'); | ||
$this->addSql('CREATE UNIQUE INDEX package_version ON organization_package_version (package_id, version)'); | ||
$this->addSql('COMMENT ON COLUMN organization_package_version.id IS \'(DC2Type:uuid)\''); | ||
$this->addSql('COMMENT ON COLUMN organization_package_version.package_id IS \'(DC2Type:uuid)\''); | ||
$this->addSql('COMMENT ON COLUMN organization_package_version.date IS \'(DC2Type:datetime_immutable)\''); | ||
$this->addSql('ALTER TABLE organization_package_version ADD CONSTRAINT FK_62DF469AF44CABFF FOREIGN KEY (package_id) REFERENCES organization_package (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); | ||
} | ||
|
||
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('DROP TABLE organization_package_version'); | ||
} | ||
} |
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\Query\User\Model; | ||
|
||
final class Version | ||
{ | ||
private string $version; | ||
private string $reference; | ||
private int $size; | ||
private \DateTimeImmutable $date; | ||
|
||
public function __construct(string $version, string $reference, int $size, \DateTimeImmutable $date) | ||
{ | ||
$this->version = $version; | ||
$this->reference = $reference; | ||
$this->size = $size; | ||
$this->date = $date; | ||
} | ||
|
||
public function version(): string | ||
{ | ||
return $this->version; | ||
} | ||
|
||
public function reference(): string | ||
{ | ||
return $this->reference; | ||
} | ||
|
||
public function size(): int | ||
{ | ||
return $this->size; | ||
} | ||
|
||
public function date(): \DateTimeImmutable | ||
{ | ||
return $this->date; | ||
} | ||
} |
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
Oops, something went wrong.