Add flags property to Notification entity + migraiton

This commit is contained in:
Julie Lenaerts 2025-06-10 12:27:38 +02:00
parent 5ee8a6bc82
commit 1c426f560e
3 changed files with 54 additions and 0 deletions

View File

@ -100,6 +100,9 @@ class Notification implements TrackUpdateInterface
#[ORM\ManyToOne(targetEntity: User::class)]
private ?User $updatedBy = null;
#[ORM\Column(name: 'flags', type: \Doctrine\DBAL\Types\Types::JSON, nullable: false, options: ['default' => '[]', 'jsonb' => true])]
private $flags = [];
public function __construct()
{
$this->addressees = new ArrayCollection();
@ -389,4 +392,16 @@ class Notification implements TrackUpdateInterface
return $this;
}
public function setFlags(array $flags = []): self
{
$this->flags = $flags;
return $this;
}
public function getFlags(): array
{
return $this->flags;
}
}

View File

@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Main;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20250610102020 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add flags property to ';
}
public function up(Schema $schema): void
{
$this->addSql(<<<'SQL'
ALTER TABLE chill_main_notification ADD flags JSONB DEFAULT '[]' NOT NULL
SQL);
}
public function down(Schema $schema): void
{
$this->addSql(<<<'SQL'
ALTER TABLE chill_main_notification DROP flags
SQL);
}
}

View File

@ -14,6 +14,15 @@
"config/routes/annotations.yaml"
]
},
"doctrine/deprecations": {
"version": "1.1",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "1.0",
"ref": "87424683adc81d7dc305eefec1fced883084aab9"
}
},
"doctrine/doctrine-bundle": {
"version": "2.13",
"recipe": {