Clean migration for main bundle

This commit is contained in:
Julie Lenaerts 2024-09-19 14:37:57 +02:00 committed by Julien Fastré
parent de711181df
commit 82cb359072
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
10 changed files with 42 additions and 10 deletions

View File

@ -36,7 +36,7 @@ class Center implements HasCenterInterface, \Stringable
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255)] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255)]
private string $name = ''; private string $name = '';
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => true])]
private bool $isActive = true; private bool $isActive = true;
/** /**

View File

@ -39,7 +39,7 @@ class Country
* @var array<string, string> * @var array<string, string>
*/ */
#[Groups(['read', 'docgen:read'])] #[Groups(['read', 'docgen:read'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, options: ['default' => '[]', 'jsonb' => true])]
#[Context(['is-translatable' => true], groups: ['docgen:read'])] #[Context(['is-translatable' => true], groups: ['docgen:read'])]
private array $name = []; private array $name = [];

View File

@ -30,7 +30,7 @@ class CronJobExecution
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: true, options: ['default' => null])] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: true, options: ['default' => null])]
private ?int $lastStatus = null; private ?int $lastStatus = null;
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, options: ['default' => "'{}'::jsonb", 'jsonb' => true])] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, options: ['default' => '{}', 'jsonb' => true])]
private array $lastExecutionData = []; private array $lastExecutionData = [];
public function __construct( public function __construct(

View File

@ -39,7 +39,7 @@ class DashboardConfigItem
private ?User $user = null; private ?User $user = null;
#[Serializer\Groups(['dashboardConfigItem:read'])] #[Serializer\Groups(['dashboardConfigItem:read'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, options: ['default' => '[]', 'jsonb' => true])] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, options: ['default' => '{}', 'jsonb' => true])]
private array $metadata = []; private array $metadata = [];
public function getId(): ?int public function getId(): ?int

View File

@ -26,7 +26,7 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
class Location implements TrackCreationInterface, TrackUpdateInterface class Location implements TrackCreationInterface, TrackUpdateInterface
{ {
#[Serializer\Groups(['read'])] #[Serializer\Groups(['read'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: true)] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => true])]
private bool $active = true; private bool $active = true;
#[Serializer\Groups(['read', 'write', 'docgen:read'])] #[Serializer\Groups(['read', 'write', 'docgen:read'])]

View File

@ -34,7 +34,7 @@ class LocationType
final public const STATUS_REQUIRED = 'required'; final public const STATUS_REQUIRED = 'required';
#[Serializer\Groups(['read'])] #[Serializer\Groups(['read'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: true)] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => true])]
private bool $active = true; private bool $active = true;
#[Serializer\Groups(['read'])] #[Serializer\Groups(['read'])]
@ -54,7 +54,7 @@ class LocationType
private ?string $defaultFor = null; private ?string $defaultFor = null;
#[Serializer\Groups(['read'])] #[Serializer\Groups(['read'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => true])]
private bool $editableByUsers = true; private bool $editableByUsers = true;
#[Serializer\Groups(['read', 'docgen:read'])] #[Serializer\Groups(['read', 'docgen:read'])]

View File

@ -41,7 +41,7 @@ class Notification implements TrackUpdateInterface
* *
* @var array|string[] * @var array|string[]
*/ */
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, options: ['default' => '[]', 'jsonb' => true])]
private array $addressesEmails = []; private array $addressesEmails = [];
/** /**

View File

@ -24,7 +24,7 @@ class PermissionsGroup
/** /**
* @var string[] * @var string[]
*/ */
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, options: ['default' => '[]', 'jsonb' => true])]
private array $flags = []; private array $flags = [];
/** /**

View File

@ -45,7 +45,7 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter
/** /**
* Array where SAML attributes's data are stored. * Array where SAML attributes's data are stored.
*/ */
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, nullable: false)] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, nullable: false, options: ['default' => '[]', 'jsonb' => true])]
private array $attributes = []; private array $attributes = [];
#[ORM\ManyToOne(targetEntity: Civility::class)] #[ORM\ManyToOne(targetEntity: Civility::class)]

View File

@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Main;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20240918150339 extends AbstractMigration
{
public function getDescription(): string
{
return 'Set not null and defaults on columns. Drop customs column on address';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_main_address DROP customs');
$this->addSql('ALTER TABLE chill_main_dashboard_config_item ALTER metadata SET NOT NULL');
$this->addSql('ALTER TABLE chill_main_location ALTER active SET NOT NULL');
$this->addSql('ALTER TABLE chill_main_location_type ALTER active SET NOT NULL');
$this->addSql('ALTER TABLE chill_main_location_type ALTER editablebyusers SET NOT NULL');
$this->addSql('ALTER TABLE country ALTER name SET NOT NULL');
$this->addSql('ALTER TABLE permission_groups ALTER name SET DEFAULT \'\'');
$this->addSql('ALTER TABLE users ALTER attributes SET DEFAULT \'[]\'');
}
public function down(Schema $schema): void
{
}
}