Skip to content

Commit

Permalink
Fix NotificationReport
Browse files Browse the repository at this point in the history
  • Loading branch information
0db0 committed Mar 26, 2020
1 parent f65ac9a commit ab51910
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Command/NotifyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$email = $this->redis->get($key, function (){});
$email = unserialize($email);
$this->emailService->sendEmail($email);
report->changeStatus($status);
// report->changeStatus($status);
$this->redis->delete($key);

}
Expand Down
12 changes: 6 additions & 6 deletions src/Entity/NotificationReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class NotificationReport
private $sender;

/**
* @ORM\Column(type="object")
* @ORM\Column(type="integer")
*/
private $recipient;
private $recipientId;

/**
* @ORM\Column(type="string", length=15)
Expand All @@ -37,7 +37,7 @@ class NotificationReport
public function __construct(User $sender, User $recipient)
{
$this->sender = $sender;
$this->recipient = $recipient;
$this->recipientId = $recipient->getId();
$this->status = self::NOTIFICATION_STATUS_PENDING;
}

Expand All @@ -58,14 +58,14 @@ public function setSender(User $sender): self
return $this;
}

public function getRecipient(): ?User
public function getRecipient(): int
{
return $this->recipient;
return $this->recipientId;
}

public function setRecipient(User $recipient): self
{
$this->recipient = $recipient;
$this->recipientId = $recipient->getId();

return $this;
}
Expand Down
36 changes: 36 additions & 0 deletions src/Migrations/Version20200326105828.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

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

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200326105828 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() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('CREATE TABLE notification_report (id INT AUTO_INCREMENT NOT NULL, sender_id INT DEFAULT NULL, recipient LONGTEXT NOT NULL COMMENT \'(DC2Type:object)\', status VARCHAR(15) NOT NULL, INDEX IDX_8889D9F624B39D (sender_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE notification_report ADD CONSTRAINT FK_8889D9F624B39D FOREIGN KEY (sender_id) REFERENCES user (id)');
}

public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('DROP TABLE notification_report');
}
}
35 changes: 35 additions & 0 deletions src/Migrations/Version20200326110140.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

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

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200326110140 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() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE notification_report CHANGE recipient recipient INT NOT NULL');
}

public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE notification_report CHANGE recipient recipient LONGTEXT CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci` COMMENT \'(DC2Type:object)\'');
}
}

0 comments on commit ab51910

Please sign in to comment.