I recently upgraded my Symfony project from 5.4 to 6.4.13. Now, I am encountering an issue with Doctrine Migrations in my Symfony project. When I run the doctrine:migrations:diff
command, it generates an ALTER TABLE
statement to change a column type and default value. However, after applying the migration and running the doctrine:migrations:diff
command again, the same ALTER TABLE
statement is generated repeatedly.
Here is the generated SQL statement:
$this->addSql('ALTER TABLE my_entity CHANGE my_column my_column DOUBLE PRECISION DEFAULT 0');
Entity:
#[ORMEntity]
class MyEntity
{
...
#[ORMColumn(type: 'float', nullable: true, options: ['default' => 0])]
#[AssertRange(min: 0)]
private ?float $myColumn = 0;
...
}
Migration Configuration:
doctrine.yaml:
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
orm:
auto_generate_proxy_classes: true
mappings:
App:
type: attribute
is_bundle: false
dir: '%kernel.project_dir%/src/Entity'
prefix: 'AppEntity'
alias: App
doctrine_migrations.yaml:
doctrine_migrations:
migrations_paths:
'AppMigrations': '%kernel.project_dir%/src/Migrations'
storage:
table_storage:
table_name: 'migration_versions'
version_column_name: 'version'
version_column_length: 192
executed_at_column_name: 'executed_at'
check_database_platform: true
Project Details:
- Symfony version: 6.4.13
- PHP version: 8.1
- Composer dependencies include doctrine/doctrine-migrations-bundle v3.3.1 and doctrine/doctrine-bundle v2.13.1.
Question:
Why, in the first place, does Doctrine generate this ALTER TABLE
statement, and why does Doctrine keep generating the same ALTER TABLE
statement, after it has been executed?