Add flags property to User entity + migraiton

This commit is contained in:
Julie Lenaerts 2025-06-10 12:31:54 +02:00
parent 1c426f560e
commit c917c42789
2 changed files with 41 additions and 0 deletions

View File

@ -116,6 +116,9 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter
#[PhonenumberConstraint]
private ?PhoneNumber $phonenumber = null;
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, nullable: false, options: ['default' => '[]', 'jsonb' => true])]
private $notificationFlags = [];
/**
* User constructor.
*/
@ -613,4 +616,13 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter
return $this;
}
public function getNotificationFlagData(string $flag): array
{
return $this->notificationFlags[$flag] ?? [];
}
public function setNotificationFlagData(string $flag, array $data): void
{
$this->notificationFlags[$flag] = $data;
}
}

View File

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