Skip to content

Commit

Permalink
feat(project-sheet): Fix blameable
Browse files Browse the repository at this point in the history
  • Loading branch information
plduthoit committed Oct 16, 2024
1 parent 3caf2e4 commit 55a40ff
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
3 changes: 2 additions & 1 deletion symfony/fixtures/projects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ App\Entity\Project:
projectManagerTel: <phoneNumber()>
projectManagerPhoto: 'https://randomuser.me/api/portraits/men/<randomNumber(1, 92)>.jpg'
website: <url()>
logo: <imageUrl(200, 100)>
logo: <imageUrl(200, 100)>
createdBy: '@user_*'
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241016122346 extends AbstractMigration
final class Version20241016124248 extends AbstractMigration
{
public function getDescription(): string
{
Expand All @@ -20,23 +20,31 @@ public function getDescription(): string
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE project ADD created_by INT DEFAULT NULL');
$this->addSql('ALTER TABLE project ADD updated_by INT DEFAULT NULL');
$this->addSql('ALTER TABLE project ADD deliverables TEXT DEFAULT NULL');
$this->addSql('ALTER TABLE project ADD calendar TEXT DEFAULT NULL');
$this->addSql('ALTER TABLE project ADD created_by VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE project ADD updated_by VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE project ADD slug VARCHAR(128) DEFAULT NULL');
$this->addSql('ALTER TABLE project ADD CONSTRAINT FK_2FB3D0EEDE12AB56 FOREIGN KEY (created_by) REFERENCES "user" (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE project ADD CONSTRAINT FK_2FB3D0EE16FE72E1 FOREIGN KEY (updated_by) REFERENCES "user" (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE UNIQUE INDEX UNIQ_2FB3D0EE989D9B62 ON project (slug)');
$this->addSql('CREATE INDEX IDX_2FB3D0EEDE12AB56 ON project (created_by)');
$this->addSql('CREATE INDEX IDX_2FB3D0EE16FE72E1 ON project (updated_by)');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE project DROP CONSTRAINT FK_2FB3D0EEDE12AB56');
$this->addSql('ALTER TABLE project DROP CONSTRAINT FK_2FB3D0EE16FE72E1');
$this->addSql('DROP INDEX UNIQ_2FB3D0EE989D9B62');
$this->addSql('ALTER TABLE project DROP deliverables');
$this->addSql('ALTER TABLE project DROP calendar');
$this->addSql('DROP INDEX IDX_2FB3D0EEDE12AB56');
$this->addSql('DROP INDEX IDX_2FB3D0EE16FE72E1');
$this->addSql('ALTER TABLE project DROP created_by');
$this->addSql('ALTER TABLE project DROP updated_by');
$this->addSql('ALTER TABLE project DROP deliverables');
$this->addSql('ALTER TABLE project DROP calendar');
$this->addSql('ALTER TABLE project DROP slug');
}
}
4 changes: 2 additions & 2 deletions symfony/src/Entity/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\QueryParameter;
use App\Controller\Project\SimilarProjectsAction;
use App\Entity\Trait\SluggableEntity;
use App\Repository\ProjectRepository;
use App\Entity\Trait\SluggableEntity;
use App\Entity\Trait\TimestampableEntity;
use App\Entity\Trait\BlameableEntity;
use Doctrine\Common\Collections\Collection;
use Jsor\Doctrine\PostGIS\Types\PostGISType;
use Doctrine\Common\Collections\ArrayCollection;
use Gedmo\Blameable\Traits\BlameableEntity;
use Symfony\Component\Serializer\Attribute\Groups;

#[ORM\Entity(repositoryClass: ProjectRepository::class)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Serializer\Attribute\Groups;

trait BlameableEntityTrait
trait BlameableEntity
{
#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL', name: 'created_by')]
Expand Down

0 comments on commit 55a40ff

Please sign in to comment.