mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
update schema to send to emails
This commit is contained in:
parent
e6169ddffa
commit
ef9fd80ad5
@ -105,12 +105,25 @@ class Notification implements TrackUpdateInterface
|
|||||||
*/
|
*/
|
||||||
private ?User $updatedBy;
|
private ?User $updatedBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* a list of destinee which will receive notifications
|
||||||
|
* @var array|string[]
|
||||||
|
* @ORM\Column(type="json")
|
||||||
|
*/
|
||||||
|
public array $adressesEmails = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="text", nullable=false)
|
||||||
|
*/
|
||||||
|
private string $accessKey;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->addressees = new ArrayCollection();
|
$this->addressees = new ArrayCollection();
|
||||||
$this->unreadBy = new ArrayCollection();
|
$this->unreadBy = new ArrayCollection();
|
||||||
$this->comments = new ArrayCollection();
|
$this->comments = new ArrayCollection();
|
||||||
$this->setDate(new DateTimeImmutable());
|
$this->setDate(new DateTimeImmutable());
|
||||||
|
$this->accessKey = bin2hex(openssl_random_pseudo_bytes(24));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addAddressee(User $addressee): self
|
public function addAddressee(User $addressee): self
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\Migrations\Main;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
final class Version20220413154743 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'add access keys and emails dest to notifications';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE chill_main_notification ADD adressesEmails JSON NOT NULL DEFAULT \'[]\';');
|
||||||
|
$this->addSql('ALTER TABLE chill_main_notification ADD accessKey TEXT DEFAULT NULL');
|
||||||
|
$this->addSql('WITH randoms AS (select
|
||||||
|
n.id,
|
||||||
|
string_agg(substr(characters, (random() * length(characters) + 0.5)::integer, 1), \'\') as random_word
|
||||||
|
from (values(\'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\')) as symbols(characters)
|
||||||
|
-- length of word
|
||||||
|
join generate_series(1, 16) on 1 = 1
|
||||||
|
JOIN chill_main_notification n ON true
|
||||||
|
GROUP BY n.id)
|
||||||
|
UPDATE chill_main_notification SET accessKey = randoms.random_word FROM randoms WHERE chill_main_notification.id = randoms.id');
|
||||||
|
$this->addSql('ALTER TABLE chill_main_notification ALTER accessKey DROP DEFAULT');
|
||||||
|
$this->addSql('ALTER TABLE chill_main_notification ALTER accessKey SET NOT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE chill_main_notification DROP adressesEmails');
|
||||||
|
$this->addSql('ALTER TABLE chill_main_notification DROP accessKey');
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user