DDC-2843: SchemaTool update SQL always contains queries to set default value on columns, even if they haven't changed. #3549

Open
opened 2026-01-22 14:22:10 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Dec 7, 2013).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user pamil:

For example, I've got this schema:

use Doctrine\ORM\Mapping as ORM;

/****
 * @ORM\Table(name="tbl_company")
 * @ORM\Entity
 */
class Company
{
    /****
     * @ORM\Column(name="verified", type="boolean", nullable=false, options={"default"=false})
     */
    protected $verified = false;
}

I introduce column "verified", which is not nullable and this way I want all old entries to automatically update - it works. Then, I'm working and doing another updates. In every update SQL there is ALTER query, though default value haven't been changed since I had created it.
ALTER TABLE tbl_company ALTER verified SET DEFAULT 'false';

Shouldn't it check for changes and apply this query only if default value is changed? When I'm creating migrations, there are about ~60 queries which doesn't change anything and ex. 1 which does - it's very distracting.

Originally created by @doctrinebot on GitHub (Dec 7, 2013). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user pamil: For example, I've got this schema: ``` php use Doctrine\ORM\Mapping as ORM; /**** * @ORM\Table(name="tbl_company") * @ORM\Entity */ class Company { /**** * @ORM\Column(name="verified", type="boolean", nullable=false, options={"default"=false}) */ protected $verified = false; } ``` I introduce column "verified", which is not nullable and this way I want all old entries to automatically update - it works. Then, I'm working and doing another updates. In every update SQL there is ALTER query, though default value haven't been changed since I had created it. `ALTER TABLE tbl_company ALTER verified SET DEFAULT 'false';` Shouldn't it check for changes and apply this query only if default value is changed? When I'm creating migrations, there are about ~60 queries which doesn't change anything and ex. 1 which does - it's very distracting.
admin added the Bug label 2026-01-22 14:22:10 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3549