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

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

Originally created by @henrypenny 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 @henrypenny 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" ] }, ```
Author
Owner

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

@henrypenny i got the same issue for months already. there was a issue about this but i can't find it anymore.

I got this issue with every ORM\Column that use 'options' at every 'make:migration' it will be added again

@dvdknaap commented on GitHub (Sep 17, 2020): @henrypenny i got the same issue for months already. there was a issue about this but i can't find it anymore. I got this issue with every ORM\Column that use 'options' at every 'make:migration' it will be added again
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6542