Clean migration for activity bundle

This commit is contained in:
Julie Lenaerts 2024-09-19 14:37:05 +02:00 committed by Julien Fastré
parent e043b0cf12
commit f2eaf23c2a
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
3 changed files with 39 additions and 7 deletions

View File

@ -32,8 +32,8 @@ class ActivityReason
#[ORM\GeneratedValue(strategy: 'AUTO')] #[ORM\GeneratedValue(strategy: 'AUTO')]
private ?int $id = null; private ?int $id = null;
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, options: ['default' => '{}', 'jsonb' => true])]
private array $name; private array $name = [];
/** /**
* Get active. * Get active.

View File

@ -31,11 +31,9 @@ class ActivityReasonCategory implements \Stringable
#[ORM\GeneratedValue(strategy: 'AUTO')] #[ORM\GeneratedValue(strategy: 'AUTO')]
private ?int $id = null; private ?int $id = null;
/**
* @var string #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, options: ['default' => '{}', 'jsonb' => true])]
*/ private array $name = [];
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)]
private $name;
/** /**
* Array of ActivityReason. * Array of ActivityReason.

View File

@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Activity;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20240918142723 extends AbstractMigration
{
public function getDescription(): string
{
return 'Fix not null and default values for activityreason, activityreasoncategory, comments on activity';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE activity ALTER privatecomment_comments SET NOT NULL');
$this->addSql('ALTER TABLE activityreason ALTER name SET DEFAULT \'{}\'');
$this->addSql('ALTER TABLE activityreason ALTER name SET NOT NULL');
$this->addSql('ALTER INDEX idx_654a2fcd12469de2 RENAME TO IDX_AF82522312469DE2');
$this->addSql('ALTER TABLE activityreasoncategory ALTER name SET DEFAULT \'{}\'');
$this->addSql('ALTER TABLE activityreasoncategory ALTER name SET NOT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE activityreason ALTER name DROP DEFAULT');
$this->addSql('ALTER TABLE activityreason ALTER name DROP NOT NULL');
$this->addSql('ALTER TABLE activityreasoncategory ALTER name DROP DEFAULT');
$this->addSql('ALTER TABLE activityreasoncategory ALTER name DROP NOT NULL');
}
}