bin/console make:migration creates same migration over and over #6540

Closed
opened 2026-01-22 15:34:47 +01:00 by admin · 1 comment
Owner

Originally created by @afkernohan on GitHub (Sep 17, 2020).

I have the following field definition:

* @ORM\Column(name="id", type="string", length=100, nullable=false, options={"charset"="utf8mb4", "collation"="utf8mb4_unicode_ci"})

When I do bin/console make:migration it generates this:

    public function up(Schema $schema) : void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

        $this->addSql('ALTER TABLE oauth_access_tokens CHANGE id id VARCHAR(100) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`');
    }

    public function down(Schema $schema) : void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

        $this->addSql('ALTER TABLE oauth_access_tokens CHANGE id id VARCHAR(100) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`');
    }

The up and down statements are identical. Also, if I run the migration and then do bin/console make:migration it creates the same migration again... if I make real mapping changes, each new migration includes the statements above.

I've seen this behaviour before and it was a subtle and semantically meaningless variation in the annotation syntax that tripped things up.

I think perhaps a final sanity check to ensure the up and down statements aren't identical might be a good addition.

"doctrine/orm": {
    "version": "v2.7.3"
},
"doctrine/migrations": {
    "version": "v1.8.1"
},
"doctrine/annotations": {
    "version": "1.0",
    "recipe": {
        "repo": "github.com/symfony/recipes",
        "branch": "master",
        "version": "1.0",
        "ref": "a2759dd6123694c8d901d0ec80006e044c2e6457"
    },
    "files": [
        "config/routes/annotations.yaml"
    ]
},
Originally created by @afkernohan on GitHub (Sep 17, 2020). I have the following field definition: * @ORM\Column(name="id", type="string", length=100, nullable=false, options={"charset"="utf8mb4", "collation"="utf8mb4_unicode_ci"}) When I do `bin/console make:migration` it generates this: ``` public function up(Schema $schema) : void { // this up() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); $this->addSql('ALTER TABLE oauth_access_tokens CHANGE id id VARCHAR(100) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`'); } public function down(Schema $schema) : void { // this down() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); $this->addSql('ALTER TABLE oauth_access_tokens CHANGE id id VARCHAR(100) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`'); } ``` The up and down statements are identical. Also, if I run the migration and then do `bin/console make:migration` it creates the same migration again... if I make *real* mapping changes, each new migration includes the statements above. I've seen this behaviour before and it was a subtle and semantically meaningless variation in the annotation syntax that tripped things up. I think perhaps a final sanity check to ensure the up and down statements aren't identical might be a good addition. "doctrine/orm": { "version": "v2.7.3" }, "doctrine/migrations": { "version": "v1.8.1" }, "doctrine/annotations": { "version": "1.0", "recipe": { "repo": "github.com/symfony/recipes", "branch": "master", "version": "1.0", "ref": "a2759dd6123694c8d901d0ec80006e044c2e6457" }, "files": [ "config/routes/annotations.yaml" ] },
admin closed this issue 2026-01-22 15:34:47 +01:00
Author
Owner

@afkernohan commented on GitHub (Sep 17, 2020):

I posted this in my bosses account by accident. I'm going to repost as myself.

@afkernohan commented on GitHub (Sep 17, 2020): I posted this in my bosses account by accident. I'm going to repost as myself.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6540