Skip to content

Commit 7e2ecc0

Browse files
committed
Extrafield: Change boolean columns (visible_to_self, visible_to_others, changeable, filter) to not accept null values - refs BT#21568
1 parent e003ffc commit 7e2ecc0

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

src/CoreBundle/Entity/ExtraField.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ class ExtraField
126126
#[ORM\Column(name: 'field_order', type: 'integer', unique: false, nullable: true)]
127127
protected ?int $fieldOrder = null;
128128

129-
#[ORM\Column(name: 'visible_to_self', type: 'boolean', unique: false, nullable: true)]
129+
#[ORM\Column(name: 'visible_to_self', type: 'boolean', options: ['default' => false])]
130130
protected ?bool $visibleToSelf = false;
131-
#[ORM\Column(name: 'visible_to_others', type: 'boolean', unique: false, nullable: true)]
131+
#[ORM\Column(name: 'visible_to_others', type: 'boolean', options: ['default' => false])]
132132
protected ?bool $visibleToOthers = false;
133133

134-
#[ORM\Column(name: 'changeable', type: 'boolean', unique: false, nullable: true)]
134+
#[ORM\Column(name: 'changeable', type: 'boolean', options: ['default' => false])]
135135
protected ?bool $changeable = false;
136136

137-
#[ORM\Column(name: 'filter', type: 'boolean', unique: false, nullable: true)]
137+
#[ORM\Column(name: 'filter', type: 'boolean', options: ['default' => false])]
138138
protected ?bool $filter = false;
139139

140140
/**
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/* For licensing terms, see /license.txt */
4+
5+
declare(strict_types=1);
6+
7+
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
8+
9+
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
10+
use Doctrine\DBAL\Schema\Schema;
11+
12+
class Version20241209103000 extends AbstractMigrationChamilo
13+
{
14+
15+
public function getDescription(): string
16+
{
17+
return "Change extra field boolean columns (visible_to_self, visible_to_others, changeable, filter) to not accept null values.";
18+
}
19+
20+
/**
21+
* @inheritDoc
22+
*/
23+
public function up(Schema $schema): void
24+
{
25+
$this->addSql("UPDATE extra_field SET visible_to_self = 0 WHERE visible_to_self IS NULL");
26+
$this->addSql("UPDATE extra_field SET visible_to_others = 0 WHERE visible_to_others IS NULL");
27+
$this->addSql("UPDATE extra_field SET changeable = 0 WHERE changeable IS NULL");
28+
$this->addSql("UPDATE extra_field SET filter = 0 WHERE filter IS NULL");
29+
30+
$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");
31+
}
32+
}

0 commit comments

Comments
 (0)