Extrafield: Change boolean columns (visible_to_self, visible_to_others, changeable, filter) to not accept null values - refs BT#21568

pull/5949/head
Angel Fernando Quiroz Campos 9 months ago
parent e003ffc01d
commit 7e2ecc03d7
No known key found for this signature in database
GPG Key ID: B284841AE3E562CD
  1. 8
      src/CoreBundle/Entity/ExtraField.php
  2. 32
      src/CoreBundle/Migrations/Schema/V200/Version20241209103000.php

@ -126,15 +126,15 @@ class ExtraField
#[ORM\Column(name: 'field_order', type: 'integer', unique: false, nullable: true)]
protected ?int $fieldOrder = null;
#[ORM\Column(name: 'visible_to_self', type: 'boolean', unique: false, nullable: true)]
#[ORM\Column(name: 'visible_to_self', type: 'boolean', options: ['default' => false])]
protected ?bool $visibleToSelf = false;
#[ORM\Column(name: 'visible_to_others', type: 'boolean', unique: false, nullable: true)]
#[ORM\Column(name: 'visible_to_others', type: 'boolean', options: ['default' => false])]
protected ?bool $visibleToOthers = false;
#[ORM\Column(name: 'changeable', type: 'boolean', unique: false, nullable: true)]
#[ORM\Column(name: 'changeable', type: 'boolean', options: ['default' => false])]
protected ?bool $changeable = false;
#[ORM\Column(name: 'filter', type: 'boolean', unique: false, nullable: true)]
#[ORM\Column(name: 'filter', type: 'boolean', options: ['default' => false])]
protected ?bool $filter = false;
/**

@ -0,0 +1,32 @@
<?php
/* For licensing terms, see /license.txt */
declare(strict_types=1);
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
class Version20241209103000 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
return "Change extra field boolean columns (visible_to_self, visible_to_others, changeable, filter) to not accept null values.";
}
/**
* @inheritDoc
*/
public function up(Schema $schema): void
{
$this->addSql("UPDATE extra_field SET visible_to_self = 0 WHERE visible_to_self IS NULL");
$this->addSql("UPDATE extra_field SET visible_to_others = 0 WHERE visible_to_others IS NULL");
$this->addSql("UPDATE extra_field SET changeable = 0 WHERE changeable IS NULL");
$this->addSql("UPDATE extra_field SET filter = 0 WHERE filter IS NULL");
$this->addSql("ALTER TABLE extra_field CHANGE visible_to_self visible_to_self TINYINT(1) DEFAULT 0 NOT NULL, CHANGE visible_to_others visible_to_others TINYINT(1) DEFAULT 0 NOT NULL, CHANGE changeable changeable TINYINT(1) DEFAULT 0 NOT NULL, CHANGE filter filter TINYINT(1) DEFAULT 0 NOT NULL");
}
}
Loading…
Cancel
Save