Skip to content

Do not use nowdocs by default or provide an option to opt-out #1506

@theofidry

Description

@theofidry

Feature Request

Q A
New Feature no
RFC no
BC Break no
Version 3.9.0+

Summary

With #1473 the result if a regular diff (bin/console doctrine:migration:diff) is now:

<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20250530065231 extends AbstractMigration
{
    public function getDescription(): string
    {
        return '';
    }

    public function up(Schema $schema): void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql(<<<'SQL'
            ALTER TABLE platform ADD test_number INT NOT NULL
        SQL);
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql(<<<'SQL'
            ALTER TABLE platform DROP test_number
        SQL);
    }
}

There is a --formatted that, AFAIU, was providing this functionality. So now effectively what we have is:

  • an option that is not deprecated but provide no value
  • the default behaviour that changed to the formatted behaviour
  • no way to opt out of it

Solution

I don't know if reverting it is desired and personally I understand the appeal of promoting type-checkable* statements as the default. Personally I find it's a bit too much especially for simple statements, if statements were grouped I think it would make it more readable, but that cannot be done with prepared statements.

However I think it's important to have a way to opt-out to this. Maybe via a new option and a corresponding config setting in the bundle.

*: Referring to the fact that adding 'SQL' tags to the nowdocs the IDE can pick it up and syntax check/highlight it and even match against the DB schema.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions